我哪裏行使用AngularJS ngRpeat生成的表格:如果我有什麼適用ngClass到ngRepeat聲明元素
$scope.divison = [
{
name: "John Doe",
score: "10",
goingUp : true
},
{
name: "Bob Marley",
score: "20"
}
];
現在:
<tr ng-repeat="player in division">
<td>{{player.name}}</td>
<td>{{player.score}}</td>
</tr>
數組看起來有點像這樣想要基於特定的ng-repeat
將ng-class
應用於表格行?我會雖然這可能會工作:
<tr ng-repeat="player in division" ng-class="'goingUp' : player.goingUp">
<td>{{player.name}}</td>
<td>{{player.score}}</td>
</tr>
唉這是行不通的。可能是因爲ng級不在這個重複元素之內。我怎樣才能得到這個工作?
嘗試:'ngclass =」 (player.goingUp)?'goingUp':''「' – 2014-10-16 13:11:52
ng-class =」{'goingUp':player.goingUp}「 – Second2None 2014-10-16 13:17:41
@ Second2None謝謝,我只是想念那些括號。如果你想發佈這個答案,我會接受它作爲正確的語法和最簡單的方法。 – Coop 2014-10-16 13:22:36