Mistalis Mistalis - 3 months ago 10
AngularJS Question

Changing values of {{ }} - AngularJS

I got this in my .html file :

<tr ng-repeat="collab in collabs">
<td>{{collab.firstname}}</td>
<td>{{collab.lastname}}</td>
<td>{{collab.ext}}</td>
</tr>


collab.ext
is a boolean value, and I want to show Yes when it is
true
, and No when it is
false
.

Does Angular provide something for this ? :-)

Answer

Ternary operator if ? then : else did the job great:

<tr ng-repeat="collab in collabs">
    <td>{{collab.firstname}}</td>
    <td>{{collab.lastname}}</td>
    <td>{{collab.ext ? 'Yes' : 'No'}}</td>
</tr>