3

While reading the documentation of the bindonce directive, I wonder what is the difference between bo-htmland bo-text.

  • bo-html:

evaluates "markup" and render it as html inside the element

  • bo-text:

evaluates "text" and print it as text inside the element

So, I expected this code to work:

<span bo-html="<strong>SomeText</strong>"></span>

But I got this:

Error: [$parse:syntax] Syntax Error: Token '<' not a primary expression at column 1 of the expression

<strong> being a basic markup, isn't it?

If this can't work (maybe a syntax issue..), what is the real difference between bo-text and bo-html?

Mik378
  • 21,881
  • 15
  • 82
  • 180

1 Answers1

5

If you want to throw a string into bo-html, you need to declare it as a string because it's looking for a variable.

<span bo-html="'<strong>SomeText</strong>'"></span>

another way:

$scope.myVariable = '<strong>SomeText</strong>';
<span bo-html="myVariable"></span>

The difference is just as you copied above. You can see the difference by example:

$scope.myVariable = '<strong>SomeText</strong>';
<span bo-html="myVariable"></span> //<strong>SomeText</strong> as HTML
<span bo-text="myVariable"></span> //<strong>SomeText</strong> as text
SoluableNonagon
  • 11,541
  • 11
  • 53
  • 98