Angular HTML binding

Aviad P. picture Aviad P. · Jul 21, 2015 · Viewed 563.8k times · Source

I am writing an Angular application and I have an HTML response I want to display.

How do I do that? If I simply use the binding syntax {{myVal}} it encodes all HTML characters (of course).

I need somehow to bind the innerHTML of a div to the variable value.

Answer

prolink007 picture prolink007 · Dec 22, 2015

The correct syntax is the following:

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

Documentation Reference