javascript - Is there a callback for ng-bind-html-unsafe in AngularJS -
i remove of elements brought dom this...
<div ng-bind-html-unsafe="whatever"></div>
i wrote function remove elements, need way trigger function after ng-bind-html-unsafe
complete. there callback ng-bind-html-unsafe
or better approach?
ng-bind-html-unsafe has been removed current version (1.2+) of angular. recommend using $sanitize service in new version of angular. you'll need include sanitize library , add module.
that way can whatever want once sanitize operation complete , not worry callback.
a quick , dirty implementation:
<!doctype html> <html lang="en"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.11/angular.js"></script> <script src="libs/angular/angular-sanitize.js"></script> </head> <body ng-app="myapp"> <div ng-controller="mycontroller"> <div>{{sanitized}}</div> </div> <script> angular.module('myapp', ['ngsanitize']) .controller('mycontroller', ['$scope', '$sanitize', function($scope, $sanitize) { $scope.sanitized = $sanitize('sometextfromsomesource'); // whatever want here cleaned text }]) </script> </body> </html>
Comments
Post a Comment