angular.bootstrap(document, ['app'])

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容