什么是AngularJS引导过程的详细信息?

时间:2015-01-08 17:44:05

标签: javascript angularjs

深入了解AngularJS引导过程非常有用。它何时首次加载以及调用哪些事件以及按什么顺序?

我遇到了传统的 -

  • 配置
  • 运行
  • 编译
  • 控制器
  • 链接

...解释,但这对我来说有点过于抽象。

AngularJS是否有更明确/解释的引导程序?我希望得到一个包含注入器的示例,以及如何执行模块,服务等以及按什么顺序执行。我只是没有看到这样的东西,我认为看到它会有很大的帮助。

1 个答案:

答案 0 :(得分:0)

以下是有关Angular如何启动的信息straight from the docs

Angular initializes automatically upon DOMContentLoaded event or when the angular.js 
script is evaluated if at that time document.readyState is set to 'complete'. At this 
point Angular looks for the ng-app directive which designates your application root. 
If the ng-app directive is found then Angular will:

 - load the module associated with the directive.
 - create the application injector
 - compile the DOM treating the ng-app directive as the root of the
   compilation. This allows you to tell it to treat only a portion of
   the DOM as an Angular application.