Jason Jason - 18 days ago 5
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

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>
</tr>