AngularJS bootStraping

看这个

http://www.dotnet-tricks.com/Tutorial/angularjs/5aWL261214-Understanding-AngularJS-Bootstrap-Process.html

其中提到

Angular initializes automatically upon DOMContentLoaded event or when the angular.js script is downloaded to the browser and the document.readyState is set to complete.

什么是bootstrapping呢?

 

  1. Load the module associated with the directive.

  2. Create the application injector.

  3. Compile the DOM starting from the ng-app root element.

This process is called auto-bootstrapping.

 

 

angular.bootstrap(document, [‘myApp‘]);

这其实这就是给某一个元素设置了  ng-app="myApp" 这个属性

以往看到的例子都是 <body ng-app="myApp">  这里是给document设置了 ng-app  

document是一个比<html> 还要高一个层级的

所以如果页面中已设置了ng-app就不用这句话了

AngularJS bootStraping

上一篇:为gvim (WIN7)添加YouCompleteMe插件


下一篇:百度地图距离计算,计算结果和调用百度的api一样