I wanted to try to sanitize script using $sce in AngularJS.
//Controller
angular.module('App')
.controller('SketchCtrl', function ($scope, $location, $sce , http) {
$scope.init = function () {
var sketchId = $location.path().split("/:").pop();
http.getSketch(sketchId);
}
$scope.sanitize = function (script) {
if(script){
return $sce.trustAsJs(script);
}
}
});
// View
<script ng-bind="sanitize('{Here is a script I want to sanitize}}')"></script>
But I got an error like this.
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
I know how to sanitize html but do you have any idea to sanitize script?