Angularjs ng-class

ng-class doesn't work with multiple conditions. Apply the class when both conditions are true.

Here, the public and active class should be applied when childActive is equal to the title and the list items are not empty

<li ng-class="{'open':list.items.length&&childActive==header,
'active':list.items.length&&childActive==header}"
         ng-repeat="list in listEntities">

      

+3


source to share


1 answer


You have another problem. The following, with a few conditions, works:

<input ng-model="highlightEven" type="checkbox">
<div ng-repeat="item in ['a', 'b', 'c', 'd']"
     ng-class="{even: $index % 2 === 0 && highlightEven}">{{item}}</div>

      



plunker

+2


source







All Articles