[Fixed] Angular2 parse string to html

Issue

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

Solution

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.

Leave a Reply

(*) Required, Your email will not be published