深入了解AngularJS引导过程非常有用。它何时首次加载以及调用哪些事件以及按什么顺序?
我遇到了传统的 -
...解释,但这对我来说有点过于抽象。
AngularJS是否有更明确/解释的引导程序?我希望得到一个包含注入器的示例,以及如何执行模块,服务等以及按什么顺序执行。我只是没有看到这样的东西,我认为看到它会有很大的帮助。
答案 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.