繁体   English   中英

验证$ index并设置样式

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM