angularjs - 在 Angular JS 中可以声明多少个 ng-App?

标签 angularjs

How many ng-App attributes can be declared in in Angular JS? and under what circumstances? 

据我所知,ng-app 用于 Angular JS 应用程序的自动引导。

最佳答案

http://docs.angularjs.org/api/ng.directive:ngApp

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.



TL; DR:你可以有多个,但只有第一个会被引导。

这个问题类似于:
  • How to define two angular apps / modules in one page?
  • Multiple ng-app directives on a page
  • AngularJS Multiple ng-app within a page
  • 关于angularjs - 在 Angular JS 中可以声明多少个 ng-App?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21089343/

    相关文章:

    javascript - UIB 模态背景不淡入

    javascript - 从 Angular.js 中的 View 修改方法中的数据的最佳实践

    javascript - 在某些情况下停止关闭 Angular UI Bootstrap 下拉列表?

    javascript - 不使用路由的 Angular 重新加载模板 + Controller

    javascript - 为什么我们需要 Angular 指令的链接功能

    angularjs - 在可重用的 Angular 指令中隔离范围

    javascript - 加载 Angular View

    javascript - Bootstrap 提前输入不起作用

    javascript - Angular : How to run JavaScript from inside Directive after directive is compiled and linked

    javascript - Checkboxlist ng-repeat过滤器动态angularjs