Reputation: 13573
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>
Upvotes: 2
Views: 1188
Reputation: 1874
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>
Upvotes: 4
Reputation: 870
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>
Upvotes: 2