SrAxi SrAxi - 4 months ago 10
AngularJS Question

Angularjs - Show True/False as Yes/No

Is there a simple way to show a true/false value as yes/no?

I am retrieving from the Database a JSON that contains :


[Object, Object, "WithCertification": true]


This is the html:


With Certification {{elem.WithCertification}}


Is displaying this:

With Certification true

I want it to display this:

With Certification yes

Is there a way without having to go to the controller to change the true/false to yes/no?

Anyhow I need to change it, any suggestions?

Thank you.

Answer

You can have ternary operators inside Angular Expressions, so just do this:

With Certification {{elem.WithCertification?'yes':'no'}}