【问题标题】:10 $digest() iterations reached. Aborting - Not modifying the scope in any way达到 10 次 $digest() 迭代。 Aborting - 不以任何方式修改范围
【发布时间】:2016-12-07 23:01:27
【问题描述】:

我正在使用 Angular 学习 Meteor,但我有点被这个错误难住了。

在我的文件夹结构中:

client
|_ index.html
|_ main.html
|_ main.js 

main.html 包含我想在页面上显示的模板。这是一个简单的模板。

<div ng-controller="ClassListCtrl">
    test away big boy! 
</div>

在 main.js 中我设置了模块:

import angular from 'angular';
import angularMeteor from 'angular-meteor';

angular.module('rpgGame', [
    angularMeteor
]).controller('ClassListCtrl', function($scope){
    'ngInject';
});

在 index.html 中 - 我加载应用程序,打开 ng-strict-di 并使用 ng-include 指令将 main.html 作为 div 的源:

<body ng-app="rpgGame" ng-strict-di="">
    <div ng-include src="'client/main.html'"></div>
</body>

但是,正如我在标题中提到的,我明白了

达到 10 次 $digest() 迭代。中止

现在 - 我没有以任何方式修改范围,因此我不明白为什么 angular 会调用摘要更新 - 更不用说我什至没有遍历集合或更改任何集合。为什么会抛出这个错误?

从我的控制台:

Watchers fired in the last 5 iterations: [[{"msg":"fn: constantWatch","newVal":"client/main.html"}],[{"msg":"fn: constantWatch","newVal":"client/main.html"}],[{"msg":"fn: constantWatch","newVal":"client/main.html"}],[{"msg":"fn: constantWatch","newVal":"client/main.html"}],[{"msg":"fn: constantWatch","newVal":"client/main.html"}]]

【问题讨论】:

  • 它必须与库而不是您的代码,看起来很好。这是在做什么 ng-strict-di=""
  • ng-strict-di 指令已到位,以防出现缩小问题。如果存在缩小问题,它会在开发阶段被检测到,而不仅仅是在生产中。见 www.angular-meteor.com/tutorials/socially/angular1/dynamic-template
  • 我按照他们的指示到了发球台——但也重命名了我的控制器/集合......它没有用。我将它简化为问题中提出的版本 - 仍然在那里抛出错误。重启流星。甚至重新安装了我所有的包
  • 你的代码在 git 上吗?
  • 不——这是我昨天捡到的。现在仅限本地

标签: angularjs meteor


【解决方案1】:

这不是您的代码,而是库。如果你打印 angularMeteor 你可以看到它不是一个模块。

【讨论】:

  • 请记住编辑您的答案并包含您挖掘的任何其他信息 :) 我有一些东西要向我的上级展示 - 就像代码实际损坏的原因
  • 我一定会的。
猜你喜欢
  • 2013-06-12
  • 2016-09-25
  • 1970-01-01
  • 1970-01-01
  • 2016-08-15
  • 2013-09-19
  • 2016-02-25
  • 2015-05-07
  • 2015-05-30
相关资源
最近更新 更多