angularJS总结
主要是自己的理解:
1.模块依赖与注入的理解
(1)当使用ng-app或bootstrap命令启动应用时候,会生成一个注入器实例
(2)名称相同的模块会相互覆盖,应用的所有模块都modules={}一个私有对象中,以键值对存储。
(3)依赖注入的模块,提供相同的服务。后载入的模块会覆盖先载入发模块提供的服务
2.启动过程:
1.下载文件,浏览器解析html生成DOM
2.angualrjs自执行程序
1 if (window.angular.bootstrap) { 2 //AngularJS is already loaded, so we can return here... 3 console.log('WARNING: Tried to load angular more than once.'); 4 return; 5 } 6 7 //try to bind to jquery now so that one can write jqLite(document).ready() 8 //but we will rebind on bootstrap again. 9 bindJQuery(); 10 11 publishExternalAPI(angular); 12 13 jqLite(document).ready(function() { 14 angularInit(document, bootstrap); 15 }); 16 17
如图所示,首先检测是否已经启动如果已经启动,则返回。接着绑定jquery,给angular对象填充各种方法,已经加载模块生成器。最后启动应用。
3.自定义指令