Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Render HTML content in Ionic 3/4/5

view.html

<div>{{text}}</div>

The question is that 'text' has HTML that I wish to be displayed as it should but it only shows the HTML tags and text.

What can I do to render such content?

I've tried the earlier version (Ionic 1/2) solutions and nothing seems to work with Ionic v3.

like image 550
sam_v Avatar asked Jun 26 '17 12:06

sam_v


1 Answers

You should use the innerHTML attribute binding like this:

<div [innerHTML]="text"></div>

Please take a look at the Angular docs for more information.

like image 167
sebaferreras Avatar answered Nov 01 '22 20:11

sebaferreras