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' : ''">
Comments
Post a Comment