ng-class condition changes, but not updating classes ng-class condition changes, but not updating classes angularjs angularjs

ng-class condition changes, but not updating classes


Replace:

ng-class="{'active': {{selectedCat == cat.id}}}"

With:

ng-class="{'active': selectedCat == cat.id}"

You never need to nest those curly braces like that, in Angular.

Have a look at the ng-class documentation for some more examples.


Instead of

ng-class="{'active': {{selectedCat == cat.id}}}"

use

ng-class="{active: selectedCat == cat.id}"


Hi i'm also facing the same problem. i solved the problem by the way instead of assigning the value directly to ng-class, call the separate method and return the value.

ex :

ng-class="getStyleClass(cat)"$scope.getStyleClass = function(cat)  {         return "active: selectedCat == cat.id";  }

roughly i coded. please change the method as per your requirement.