This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
10 $digest() iterations reached using $sce inside isolate scope directive 1.2.0-rc.2 #3932
Closed
Description
The following code works in 1.2.0-rc1, but is now broken in 1.2.0-rc.2 with the following error
[$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["getSafeHtml(e); newVal: {}; oldVal: {}"],["getSafeHtml(e); newVal: {}; oldVal: {}"],["getSafeHtml(e); newVal: {}; oldVal: {}"],["getSafeHtml(e); newVal: {}; oldVal: {}"],["getSafeHtml(e); newVal: {}; oldVal: {}"]]
Code snippet
angular.module('app', [])
.directive('myError', ['$sce', function ($sce) {
return {
restrict: 'E',
replace: true,
template:
'<ul ng-if="errors.length > 0">' +
'<li ng-repeat="e in errors" ng-bind-html="getSafeHtml(e)"></li>' +
'</ul>',
scope: {
errors: '='
},
link: function (scope, element, attrs) {
scope.getSafeHtml = function (html) {
return $sce.trustAsHtml(html);
};
}
};
}])
.controller('AppCtrl', [function () {
this.someerrors = ['<b>What</b> an error'];
}]);
Html
<div ng-controller="AppCtrl as ctrl" class="container">
<my-error errors="ctrl.someerrors"></my-error>
</div>