Santanu Bhattacharjee Santanu Bhattacharjee - 1 year ago 62
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?

Answer Source

You could do this with ng-class


ng-class="(cu.isread === 0)  ? 'unread' : 'read'"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download