我可以用一个NG-应用程序内另一位在AngularJS [英] Can I use one ng-app inside another one in AngularJS
问题描述
我有两个NG-应用
等;
I have two ng-app like ;
<div ng-app="app1" >
somexpression
<div ng-app="app2">
some more expression
</div>
</div>
有没有什么办法,使工作?
当我做一个嵌套的NG-应用它不工作
is there any way to make it work? when I make a nested ng-app it doesn't work
我知道我可以使用两种不同的控制器,但我不希望使用两个控制器
---- -----编辑
I know that I can use two different controller but I don't want to use two controllers ---- EDIT -----
问题是;
angular.module('AppName', [
'angular-carousel'
])
所以我需要以某种方式改变这个NG-应用指令
SO I need somehow to change this ng-app to directive
推荐答案
从AngularJS文档,答案是否定的。
From the AngularJS document, the answer is no
<一个href=\"http://docs.angularjs.org/api/ng/directive/ngApp\">http://docs.angularjs.org/api/ng/directive/ngApp
AngularJS应用程序不能相互嵌套。
AngularJS applications cannot be nested within each other.
如果不是嵌套的,那么它的确定,已经有人问这个问题,这里指:的 AngularJS一个页面内的多个NG-应用
和AnguarJS文档
And if not nested, then it's OK, someone already asked this question, refer here:AngularJS Multiple ng-app within a page and the AnguarJS document
<一个href=\"http://docs.angularjs.org/api/ng/directive/ngApp\">http://docs.angularjs.org/api/ng/directive/ngApp
只有一个AngularJS应用程序可以自动自举每个HTML文档。第一ngApp在文档中找到将被用于定义根元素自动引导作为一个应用程序。到HTML文档必须使用angular.bootstrap,而不是手动引导他们在运行多个应用程序。
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.
这篇关于我可以用一个NG-应用程序内另一位在AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!