Jason Jason - 1 year ago 71
AngularJS Question

Changing the display value based on a row value in ng-repeat

I wanted to display a value in a row in ng-repeat based on the value from the database. i wanted to do some thing like this displayed below

enter image description here

I wanted to display if value T for TRAINER and M for MANAGER. could you give me a simple and efficient way to do it.

Answer Source

You can use ternaries in {{ }}

<tr ng-repeat="data in datas">
    <td>{{ data.number }}</td>
    <td>{{ data.value == 'T' ? 'TRAINER' : (data.value == 'M' ? 'MANAGER' : data.value) }}</td>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download