0

Is it possible to use ng-class twice inside ng-repeat? once to highlight a row selected row and one to check object propeties:

<ul> <li ng-repeat="item in items" ng-class="{'someclass' : item.Id > 10 && item.color != 'red'}" ng-class = "'selected' : $index == selected"> {{item .name}} </li> </ul> 

for some reason the second ng-class(in this example selectd) is not working. The items:

 $scope.items = [ { Id: 1, name: "item1" , color : 'red' }, { Id: 20, name: "item1" , color : 'blue' }, { Id: 11, name: "item1" , color : 'white' } ]; 
1
  • @KhalidHussain thanks. Commented May 11, 2016 at 7:07

1 Answer 1

3

Put both in one ng-class - something like this:

<ul> <li ng-repeat="item in items" ng-class="{'someclass' : item.Id > 10 && item.color != 'red', 'selected' : $index == selected}"> {{item .name}} </li> </ul> 
Sign up to request clarification or add additional context in comments.

1 Comment

Works great. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.