3

ng-class is not working with multiple condition. Apply a class when both conditions are true

Here open and active class should apply when childActive is equal to header and list items is not empty

<li ng-class="{'open':list.items.length&&childActive==header,
'active':list.items.length&&childActive==header}"
         ng-repeat="list in listEntities">
2
  • plunker or fiddle demo ? Commented Dec 17, 2014 at 5:38
  • I suggest to add a function in case of having complex expressions Commented Feb 18, 2015 at 7:12

1 Answer 1

2

You have some other issue. The following, with multiple 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

Sign up to request clarification or add additional context in comments.

4 Comments

It is also not working with two classes:<div ng-repeat="item in ['a', 'b', 'c', 'd']" ng-class="{even: $index % 2 === 0 && highlightEven, even-size: $index % 2 === 0 && highlightEven}">{{item}}</div>
I don't understand what you're asking (if you're asking)
Put even-size in single-quotes: "{'even-size': $index % 2 === 0 && highlightEven}"
Thanks New Dev. Now it's working fine : plnkr.co/edit/ULJlInfSlK7SIf3o8DOG?p=preview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.