Reputation: 13450
If I have:
ng-class='{in:$first}'
What is the simplest way to make it add the in
class when $first
is true or if let's say the item.in
($scope.item.in
) value is true ?
note: $first
is because I have a ng-repeat
enclosing this line but it can be any other boolean or 0/1 value if you feel the code is incomplete.
Upvotes: 2
Views: 1082
Reputation: 7279
you can use the or operator in ng-class as such
ng-class="{myclass: condition1 || condition2}"
your element will gain the myclass
class if condition1 or condition2 is true.
Upvotes: 1
Reputation: 20189
You can use the ||
operator like this.
<div ng-class="{ in: $first || item.in }"> Test </div>
Example: http://jsfiddle.net/eLPE8/
Upvotes: 1