我在这个柱塞连杆中有我的测试示例
我的问题不是重复这一个
另外,谷歌搜索结果与Github是关于bug报告程序,而不是定义他最初试图引导的模块。
我有3个模块grandParentModule
、parentModule
和nestedModule
。
我让引导了、、和到2个嵌套的div元素,它们都很好地工作。
但是,当我试图引导grandParentModule
文档时,它就会引发控制台错误.。
这是我的
<div id="parent" ng-app="parentModule">
<div id="nested">
</div>
</div>
,这是我的脚本
angular.module('grandParentModule', []);
angular.module('parentModule', []);
angular.module('nestedModule', []);
var nestedElem = document.getElementById("nested");
angular.bootstrap(angular.element(nestedElem), ['nestedModule']);
//comment / uncomment this line to toggle the error at console
angular.bootstrap(document, ['grandParentModule']);
只有这一行angular.bootstrap(document, ['grandParentModule']);
会导致错误
未明误差:吴:btstrpd
有人能向我解释为什么会发生这种事吗?
发布于 2016-05-20 03:44:36
这不是角度引导的工作方式。
你应该只引导一个模块。
如果使用多个独立模块,则不能嵌套引导它们的DOM元素。
此外,这些模块应该是什么?
如果它们是链接的,那么它们之间必须有依赖关系,例如:
angular.module('parentModule', ['grandParentModule']);
如果您希望在自己的控制器上有一些嵌套视图,可以使用多个ng-controller
或检查网络上的ui-router
。
https://stackoverflow.com/questions/37345603
复制