我爱编程

angular.bootstrap(document, [

2016-03-15  本文已影响731人  北漂老莫

angular.bootstrap(document, ['TodoApp']);

This will work if you have your scripts loaded at the end of the page (instead of in the header).

Otherwise, the DOM will not be loaded at the time of bootstrapping the app(there won' t be any template to be compiled, the directives wont't have any effect).

angular.bootstrap(angular.element("body")[0], ["TodoApp"]);
The same as before, using body as the root of the application. It uses a selector that is not available in jqLite, so you need to have full jQuery included in the app

angular.element(document).ready(function() {
  angular.bootstrap(document);
})

This one actually waits for the DOM to be loaded, so it will even if you include your scripts in the header.
This is basically the same as jQuery's $(document).ready(), but using jqLite's angular.element.

上一篇 下一篇

猜你喜欢

热点阅读