是否可以在ng-class
内使用ng-repeat
两次?一次选择highlight
一行row
,另一行检查object
个字符:
<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>
由于某种原因,第二个ng-class
(在此示例中为selectd
)无效。
项目:
$scope.items = [
{ Id: 1, name: "item1" , color : 'red' },
{ Id: 20, name: "item1" , color : 'blue' },
{ Id: 11, name: "item1" , color : 'white' }
];
答案 0 :(得分:3)
将两者放在一个ng-class中 - 类似这样:
<ul>
<li
ng-repeat="item in items"
ng-class="{'someclass' : item.Id > 10 && item.color != 'red', 'selected' : $index == selected}">
{{item .name}}
</li>
</ul>