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.

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
gsitu322
  • 117
  • 2
  • 10

1 Answers1

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

Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225