Recursive Ng-include causing Error: $rootScope:infdig Infinite $digest Loop
Recursive Ng-include causing Error: $rootScope:infdig Infinite $digest Loop
我有一个递归的 Ng-include 导致错误:$rootScope:infdig Infinite $digest Loop
在我的ctrl中:
function getTemplate(elementType) {
console.log(elementType + '_formElement.html');
return elementType + '_formElement.html';
};
在我看来:
<div ng-repeat="element in elementList track by $index" ng-init="templateID=vm.getTemplate(element.elementType)">
<ng-include src="templateID"></ng-include>
</div>
结果: 达到 10 次 $digest() 迭代。中止!
Watchers fired in the last 5 iterations: [[{"msg":"fn: function
(c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return
b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return
d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn:
function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return
b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return
d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn:
function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return
b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return
d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn:
function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return
b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return
d(a)}","newVal":""},{"msg":"templateID","newVal":"FIELD_formElement.html"}],[{"msg":"templateID","newVal":"TEXT_field.html"},{"msg":"fn:
function (a){return d(a)}","newVal":""}]]
Console.log:
ROW_formElement.html
7 ROW_formElement.html
FIELD_formElement.html
我知道我可以像下面这样增加 TTL,但是还有其他解决方案吗?
angular.module('myApp',[])
.config(function($rootScopeProvider) {
$rootScopeProvider.digestTtl(number); //some number bigger then 10
})
我有一个递归的 Ng-include 导致错误:$rootScope:infdig Infinite $digest Loop
在我的ctrl中:
function getTemplate(elementType) {
console.log(elementType + '_formElement.html');
return elementType + '_formElement.html';
};
在我看来:
<div ng-repeat="element in elementList track by $index" ng-init="templateID=vm.getTemplate(element.elementType)">
<ng-include src="templateID"></ng-include>
</div>
结果: 达到 10 次 $digest() 迭代。中止!
Watchers fired in the last 5 iterations: [[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return d(a)}","newVal":""},{"msg":"templateID","newVal":"ROW_formElement.html"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":3},{"msg":"fn: function (a){return d(a)}","newVal":""},{"msg":"templateID","newVal":"FIELD_formElement.html"}],[{"msg":"templateID","newVal":"TEXT_field.html"},{"msg":"fn: function (a){return d(a)}","newVal":""}]]
Console.log:
ROW_formElement.html
7 ROW_formElement.html
FIELD_formElement.html
我知道我可以像下面这样增加 TTL,但是还有其他解决方案吗?
angular.module('myApp',[])
.config(function($rootScopeProvider) {
$rootScopeProvider.digestTtl(number); //some number bigger then 10
})