Reputation: 13335
I am trying to use ng-class with ng-repeat, and trying to apply a class to my first cell. My first cell should have a red background. However, it doesn't seem to have any effect.
<table>
<tbody>
<tr ng-repeat="item in items" class="item">
<td class="thing" ng-repeat="thing in things" ng-class="{thing-red: $first}"></td>
</tr>
</tbody>
</table>
.thing-red {
background:red;
}
This works as expected (all cells are red):
<td class="thing thing-red" ng-repeat="thing in things"></td>
Upvotes: 0
Views: 46
Reputation: 70
Try below code
<td class="thing" ng-repeat="thing in things" ng-class="{'thing-red': $index == 0}"></td>
Upvotes: 1