sbaaaang sbaaaang - 2 months ago 7
HTML Question

How to print html string as html

If just for example I do:

var = "<a>Asd</a>";

<span>{{ var }}</span>


The string is printed like text and not as html, so how do I print the html ?

Answer

You should be using ng-bind-html directive.

Creates a binding that will innerHTML the result of evaluating the expression into the current element in a secure way.

<ANY ng-bind-html="{expression}">
   ...
</ANY>