HTML
<div style="float:left" data-ng-repeat="x in tokens" ng-init="btnclass=false">
<button type="button" ng-class="{true:'btn btn-material-light-green btn-sm', false:'btn btn-material-grey btn-sm'}[btnclass]" ng-click="toggle($index)">{{x}}</button>
</div>
Controller file
$scope.toggle = function(i){
console.log("done"+i+" ",$scope.btnclass);
$scope.btnclass=$scope.btnclass?false:true;
console.log($scope.btnclass);
}
Console output indicates the variable btnclass
does change but I see no effect on the color of button after clicking it.
"done3 " true
false
"done3 " false
true
EDIT Since, alot of people have been questioning the syntax for ng-class expression, I wanted to clarify that this is an old syntax and it works. Refer this question.