2016-07-28 16 views
0

私はテーブル行をハイライト表示しようとしていますが、指示文の中の角度jに変換するのは難しいです。擬似コードをチェックしてください:

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}"> 
関連する問題