[英]Verify $index and set a style
我試圖突出顯示表行,但很難將其轉換為指令內的angular js。 檢查偽代碼:
if(highlight.indexOf($index) != -1) set .highlight css class
這是我的代碼的示例:
$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>
在ng-repeat
之后使用ng-class
:
<tr ng-repeat="a in as track by $index" ng-class="{highlight: highlight.indexOf($index) > -1}">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.