2016-07-28 64 views
0

我試圖突出顯示錶格行,但很難將其轉換爲指令內部的角度js。檢查的僞代碼:

if(highlight.indexOf($index) != -1) set .highlight css class 

這是我的代碼一個例子:ng-repeat

$scope.highlight = [0,2,3]
.highlight { 
 
    color: red; 
 
}
<table class="ui celled table"> 
 
    <thead> 
 
    <tr> 
 
     <th>AAA</th> 
 
     <th>BBB</th> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    <tr ng-repeat="a in as track by $index"> <!-- The ng-class needs to be here, but where should i do the verification? --> 
 
     <td>{{a}}</td> 
 
     <td>{{b[$index]}}</td> 
 
    </tr> 
 
    </tbody> 
 
</table>

回答

1

使用ng-class

<tr ng-repeat="a in as track by $index" ng-class="{highlight: highlight.indexOf($index) > -1}">