如何在一个页面中定义的两个角的应用程序/模块? [英] How to define two angular apps / modules in one page?
问题描述
我想两个角的应用程序/模块添加到一个页面。
在下面你小提琴可以看到,永远只是第一个模块,在html code引用,将正常工作,而第二个不被认可的棱角。
在此小提琴我们只能执行 doSearch2
方法,而在此小提琴只有 doSearch
法正常工作。
我在寻找的路上如何正确放置两个角模块插入到一个页面。
只有一个AngularJS应用程序可以自动自举每个HTML文档。第一ngApp在文档中找到将被用于定义根元素自动引导作为一个应用程序。要运行一个HTML文档必须使用angular.bootstrap,而不是手动引导他们在多个应用程序。 AngularJS应用程序不能相互嵌套。
- <一个href=\"http://docs.angularjs.org/api/ng.directive:ngApp\">http://docs.angularjs.org/api/ng.directive:ngApp
块引用>另请参见
- https://groups.google.com/d/msg/angular/lhbrIG5aBX4/4hYnzq2eGZwJ
- http://docs.angularjs.org/api/angular.bootstrap
I'm trying to add two angular apps / modules to one page. In the fiddles below you can see that always only the first module, referenced in the html code, will work correctly, whereas the second is not recognized by angular.
In this fiddle we can only execute the
doSearch2
method, whereas in this fiddle only thedoSearch
method works correctly.I'm looking for the way how to correctly place two angular modules into one page.
解决方案Only one AngularJS application can be auto-bootstrapped per HTML document. The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application. To run multiple applications in an HTML document you must manually bootstrap them using angular.bootstrap instead. AngularJS applications cannot be nested within each other. -- http://docs.angularjs.org/api/ng.directive:ngApp
See also
- https://groups.google.com/d/msg/angular/lhbrIG5aBX4/4hYnzq2eGZwJ
- http://docs.angularjs.org/api/angular.bootstrap
这篇关于如何在一个页面中定义的两个角的应用程序/模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!