Question

My controller holds a description which is plain HTML code. I want this to be injected into a given tag so that it is rendered according to the tags it contains.

I tried the following but the HTML is rendered in the attribute whereas I expected to be into the tag itself.

<div ng-bind-html-unsafe="{{stage.description}}"></div>
Was it helpful?

Solution 2

I don't remember since when AngularJS does not allow this anymore.

What you need to do is to include the AngularJS Sanitize library. You can download the sanitize library somewhere here: https://code.angularjs.org/1.2.16/

In your module

angular.module('myModule', ['ngSanitize'])

In your template

<div ng-bind-html="stage.description"></div>

OTHER TIPS

Remove the curly braces. The curly braces is just the templating tags. You want to bind the actual variable.

<div ng-bind-html-unsafe="stage.description"></div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top