Angular2 parse string to html

2019-03-14 06:30发布

I'm importing rss items where in description there is a lot of html code (links, paragraphs, etc...). When I'm viewing it in component's view like:

{{rss.description}}

the output in site is like:

<a href="http://link.com">Something</a> <p>Long text</p>

How can I quickly and easy parse it to html? I don't want to cross it with jQuery. Thank you

1条回答
forever°为你锁心
2楼-- · 2019-03-14 06:47

Not sure if I understand your question correctly, but this might be what you want

<div [innerHTML]="rss.description"></div>

See also In RC.1 some styles can't be added using binding syntax for how to allow "unsafe" HTML.

查看更多
登录 后发表回答