看这个
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呢?
-
Load the module associated with the directive.
-
Create the application injector.
-
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就不用这句话了