2

Hi I'm using angular and I want to do an expression in my ng-bind-html-unsafe so that it can choose between two text to show. Is this the right syntax for the expression?

<div  ng-bind-html-unsafe="{{ 0 && text || text2}}"></div>

Here's a jsfiddle that show my problem.

1 Answer 1

2

Try without braces:

  <div  ng-bind-html-unsafe=" 0 && text || text2"></div>

Output:

HELLO THERE2

for

<div  ng-bind-html-unsafe=" 1 && text || text2"></div>

Output

 HELLO THERE

Fiddle

As a side note, ng-bind-html-unsafe is removed from newer versions. In the future it can lead to errors

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

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.