Santanu Bhattacharjee Santanu Bhattacharjee - 7 months ago 21
AngularJS Question

how to add a condition in ng-repeat?

Here is my html table

<tr class="unread" ng-repeat="CU in InboxList">
<td class="text-right mail-date">{{CU.time}}</td>

<tr class="read">
<td class="text-right mail-date">12:00 pm</td>

here in my html table there are two tr class one is tr class="read" and other is class="unread" i have already binded tr class="unread".now i want to check a condition if {{cu.isread=0}} then tr class read will bind otherwise tr class unread will to do this?


You could do this with ng-class


ng-class="(cu.isread === 0)  ? 'unread' : 'read'"