Angular 2: expression containing markup

I am looking for a way to tell Angular to display a value inside an expression containing markup, and actually use HTML:

{{ value }} let value = "<span>foobar</span>"; 

So, the value variable contains a line with markup, and I want to apply markup so that it appears on the page. Therefore, if value contains <b>test</b> , then bold text will appear on the page.

+5
source share
1 answer

Guess what you're looking for innerHTML :

 value: string = "<span>foobar</span>"; <div [innerHTML]="value"> </div> 

The above code will be displayed:

 <div> <span>foobar</span> </div> 
+4
source

Source: https://habr.com/ru/post/1261857/


All Articles