通过
接收数据$scope.$watch("build.idx", ->
$http.get("/build/" + $scope.build.idx + ".json").success((data) ->
$scope.build = data
)
)
ng-include in ng-repeat
.build-stage
.row{ "ng-repeat" => "stage in build.stages" }
%div{ "ng-include" => "donoting.html" } # donoting.html is blank
首先加载页面,它没问题。并且当更改build.idx时,它会导致
10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function (){var a=d.url(),b=h.$$replace;p&&a==h.absUrl()||(p++,c.$evalAsync(function(){c.$broadcast(\"$locationChangeStart\",h.absUrl(),a).defaultPrevented?h.$$parse(a):(d.url(h.absUrl(),b),g(a))}));h.$$replace=!1;return p}; newVal: 8; oldVal: 7"],["fn: function (){var a=d.url(),b=h.$$replace;p&&a==h.absUrl()||(p++,c.$evalAsync(function(){c.$broadcast(\"$locationChangeStart\",h.absUrl(),a).defaultPrevented?h.$$parse(a):(d.url(h.absUrl(),b),g(a))}));h.$$replace=!1;return p}; newVal: 9; oldVal: 8"],["fn: function (){var a=d.url(),b=h.$$replace;p&&a==h.absUrl()||(p++,c.$evalAsync(function(){c.$broadcast(\"$locationChangeStart\",h.absUrl(),a).defaultPrevented?h.$$parse(a):(d.url(h.absUrl(),b),g(a))}));h.$$replace=!1;return p}; newVal: 10; oldVal: 9"],["fn: function (){var a=d.url(),b=h.$$replace;p&&a==h.absUrl()||(p++,c.$evalAsync(function(){c.$broadcast(\"$locationChangeStart\",h.absUrl(),a).defaultPrevented?h.$$parse(a):(d.url(h.absUrl(),b),g(a))}));h.$$replace=!1;return p}; newVal: 11; oldVal: 10"],["fn: function (){var a=d.url(),b=h.$$replace;p&&a==h.absUrl()||(p++,c.$evalAsync(function(){c.$broadcast(\"$locationChangeStart\",h.absUrl(),a).defaultPrevented?h.$$parse(a):(d.url(h.absUrl(),b),g(a))}));h.$$replace=!1;return p}; newVal: 12; oldVal: 11"]]
当删除ng-include行时,它没问题。 我认为它的ng-include会导致$ locationChangeStart被解雇,但为什么呢?
答案 0 :(得分:2)
确保要包含在ng-include中的模板路径是正确的。如果不是,则会导致10 $digest() iterations reached
错误。
如果路径不正确,服务器将提供index.html(至少在您使用html5模式的情况下,服务器默认为index.html提供服务); index.html将被包括在内并将导致ng-include指令再次运行;结果是迭代包含index.html的无限循环,它以错误消息10 $digest() iterations reached
答案 1 :(得分:0)
你的自我在这里无限循环
$scope.$watch("build.idx", ->
$http.get("/build/" + $scope.build.idx + ".json").success((data) ->
$scope.build = data
)
)
你正在关注build.idx,如果这改变了请求信息,这将改变构建,这将再次触发请求并再次修改构建变量并继续进行,这将通过不断变化在摘要周期中反映出来和angular将抛出此异常,因为它检测到可能的无限循环