3

I have code in HTML

 <li><strong>Scrub:</strong> {{insuredProfile.permanentAddress.isScrubbed}}</li>

This show either true or false i need to show Yes for true and No for false

If i use data-ng-if i can apply only one condition at a time. Can some one suggest better way to do it.Thanks

2 Answers 2

4

Simplest way would probably be using an inline if :

{{insuredProfile.permanentAddress.isScrubbed ? 'Yes' : 'No'}}

Edited as per the comments, sorry for the typo.

Sign up to request clarification or add additional context in comments.

3 Comments

What should i do for for False ?
Don't you mean 'No' instead of 'True'?
This contain one value at a time either True or False.For true i have to show Yes and for false i have to show No
2

You could write a filter which does this

(function (app) {
    app.filter('boolToYesNo', function () {
        return function (input) {
            return input ? 'yes' : 'no';
        }
    });
})(angular.module('app'));

And then call it like

{{ insuredProfile.permanentAddress.isScrubbed | boolToYesNo }}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.