ng-bind-html-unsafe
was removed in Angular 1.2
I'm trying to implement something where I need to use ng-bind-html-unsafe
. In the docs and on the github commit they say:
ng-bind-html provides ng-html-bind-unsafe like behavior (innerHTML's the result without sanitization) when bound to the result of $sce.trustAsHtml(string).
How do you do this?
Filter
Usage
Personally I sanitize all my data with some PHP libraries before going into the database so there's no need for another XSS filter for me.
From AngularJS 1.0.8
To use:
To disable
$sce
:That should be:
plus in your controller:
instead of old syntax, where you could reference
$scope.html
variable directly:As several commenters pointed out,
$sce
has to be injected in the controller, otherwise you will get$sce undefined
error.If you want the old directive back, you can add this to your app:
Directive:
Usage
Source - https://github.com/angular-ui/bootstrap/issues/813
JavaScript
HTML