使用 ng-class 在 AngularJS 中传递一个 class 名称
Pass a class name in AngularJS with ng-class
我有:
<tr ng-class="{{line.color}}" ng-repeat="line in gameRank | orderBy: sortType: sortReverse">
<td>{{$index + 1}}</td>
<td>{{line.username}}</td>
<td>{{line.games}}</td>
<td>{{line.winners}}</td>
</tr>
当我打开调试器时,我看到:
<tr class="ng-scope" ng-class="BLUE" ng-repeat="line in gameRank | orderBy: sortType: sortReverse">
<td class="ng-binding">1</td>
<td class="ng-binding">Admin</td>
<td class="ng-binding">0</td>
<td class="ng-binding">0</td>
</tr>
因此,我的 class BLUE
未应用于我的元素。
我该如何解决?
应该是
<tr ng-class="line.color" ...>
而不是
<tr ng-class="{{line.color}}" ...>
JSFiddle demo
我有:
<tr ng-class="{{line.color}}" ng-repeat="line in gameRank | orderBy: sortType: sortReverse">
<td>{{$index + 1}}</td>
<td>{{line.username}}</td>
<td>{{line.games}}</td>
<td>{{line.winners}}</td>
</tr>
当我打开调试器时,我看到:
<tr class="ng-scope" ng-class="BLUE" ng-repeat="line in gameRank | orderBy: sortType: sortReverse">
<td class="ng-binding">1</td>
<td class="ng-binding">Admin</td>
<td class="ng-binding">0</td>
<td class="ng-binding">0</td>
</tr>
因此,我的 class BLUE
未应用于我的元素。
我该如何解决?
应该是
<tr ng-class="line.color" ...>
而不是
<tr ng-class="{{line.color}}" ...>