Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between bo-html and bo-text

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?

like image 700
Mik378 Avatar asked Jul 22 '26 12:07

Mik378


1 Answers

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
like image 169
SoluableNonagon Avatar answered Jul 25 '26 00:07

SoluableNonagon