Render HTML content in Ionic v3

2019-04-18 15:16发布

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.

1条回答
等我变得足够好
2楼-- · 2019-04-18 16:03

You should use the innerHTML attribute binding like this:

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

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

查看更多
登录 后发表回答