Simplified version of problem, view web dev console: http://plnkr.co/edit/3wKmWz?p=preview
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations:
So why does passing an object into a directive with an isolated scope cause an infinite $digest() loop?
// controller
// AngularJS 1.2.x infinite digest caused when returning object into directive
$scope.ctrlObjReturnFn = function() {
return {test:true};
}
// view
<div test-dir breaking-object="ctrlObjReturnFn()"></div
// directive
app.directive('testDir', function() {
return {
scope: { breakingObject: '=' },
link: function(scope, element, attrs) {
element.html('printed obj: ' + scope.breakingObject.toString());
}
}
});