【Angular】启动过程
1、加載模板
(1)publishExternalAPI(公布Api)
? ? ? ? (1)掛載全局對象
? ? ? ? (2)創建模塊加載器
? ? ? ? (3)定義ngLocale模塊->定義$locale服務
? ? ? ? (4)定義ng模塊
(2)定義(延遲執行)
2、解析指令(Dom樹)
angularInit:DomReady
? ? ? ? (1)ng-app指令?查找appElement元素,ng-app啟動應用
? ? ? ??? ? ? ? ? ?(1)createInjector定義、創建$injector服務
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (1)創建$provide提供者
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (2)創建$injector提供者和$injector服務實例
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (3)加載ng模塊
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?定義內置服務
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (4)加載app模塊
? ? ? ??? ? ? ? ? ?(2)解析應用Dom
? ? ? ? ? ? ? ? ? ? ? ? ? ?injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animate',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? function(scope, element, compile, injector, animate) {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? scope.$apply(function() {
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? element.data('$injector', injector);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? compile(element)(scope);
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? ? ? ?]);
總結
以上是生活随笔為你收集整理的【Angular】启动过程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Angular】服务(Service)
- 下一篇: 【Angular】双向数据绑定--作用域