7

Why this return a blank string on my template?

{{ selectedVehicle.air_conditioning.replace(true, "Yes") }}
2
  • Is this all code with you? Commented Feb 16, 2015 at 11:18
  • 1
    first check the value of selectedVehicle.air_conditioning, and I don´t think you are using the replace function correctly, try putting the true value in quotes like 'true' Commented Feb 16, 2015 at 11:19

3 Answers 3

6

.replace method can't be applied on Boolean variable, it works on string only. That's why you need to convert it to string then apply replace.

{{ selectedVehicle.air_conditioning.toString().replace(true, "Yes") }}

Working Fiddle

Hope this could help you. Thanks.

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

Comments

6

Okay, if I get it:

  • air_conditioning is a boolean ?
  • you want to print yes when air_conditioning is true ?

you can just use ternary syntax like this:

{{ selectedVehicle.air_conditioning ? "Yes" : "No }}

Comments

0

With out more info it is hard to give full help. please update your post with example code, controller etc.

But that said try and have to look at this:

How to display Yes/No instead of True/False in AngularJS

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.