javascript - Toggle Classes with Local Scope -


i trying toggle active class single button in each row. can toggle class on, cannot figure out how remove once condition has changed.

please see this example.

at point have local ng-repeat variable, active, using store index of active button.

<button ng-repeat="c in lanecolors"         ng-click="lanedata[g].base = c; active = $index"         ng-class="(active===$index) ? 'active' : ''"> 

i hoped active class removed once condition, active===$index, no longer met, continues add class buttons clicked.

instead of setting active based on index, check if button value same of selected color.

<button ng-repeat="c in lanecolors"         ng-click="lanedata[g].base = c"         ng-class="(c===lanedata[g].base) ? 'active' : ''">  

demo


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -