This repository was archived by the owner on Sep 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 438
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
10 $digest() iterations reached when get options from service by method! #400
Copy link
Copy link
Closed
Labels
Description
Hi,
I have a constant
service in my app to store some global configs and options.
(function() {
'use strict';
angular.module('App.Core')
.factory('Constants', ['$rootScope', function($rootScope) {
return {
getUiSortableOptions: function() {
return {
axis: "y",
handle: ".handle",
items: "> .movable",
containment: 'parent',
revert: 50,
tolerance: 'pointer',
opacity: 0.8,
cursor: 'move'
};
}
};
}])
})();
And in my CoreCtrl
I register a global scope's variable for access in view:
(function() {
'use strict';
angular.module('App.Core')
/**
* Main site controller
*/
.controller('CoreCtrl', [ '$scope', 'Constants', function ( $scope, Constants) {
$scope.constants = Constants;
}])
;
})();
View:
<div ui-sortable="constants.getUiSortableOptions()">
....
....
</div>
But in console I receive 10 $digest() iterations reached
error:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"fn: regularInterceptedExpression","newVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"},"oldVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"}}],[{"msg":"fn: regularInterceptedExpression","newVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"},"oldVal":"..."}],[{"msg":"fn: regularInterceptedExpression","newVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"},"oldVal":"..."}],[{"msg":"fn: regularInterceptedExpression","newVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"},"oldVal":"..."}],[{"msg":"fn: regularInterceptedExpression","newVal":{"axis":"y","handle":".handle","items":"> .movable","containment":"parent","revert":50,"placeholder":"ui yellow message","tolerance":"pointer","opacity":0.8,"cursor":"move"},"oldVal":"..."}]]
So when I change CoreCtrl
& View as follow, everything works perfectly!
$scope.sortableOptions = Constants.getUiSortableOptions();
<div ui-sortable="sortableOptions">
....
....
</div>
Cheers