最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - angular bootstrapping issues angular.bootstrap not working on my apps - Stack Overflow

programmeradmin1浏览0评论

I am facing an issue with bootstrapping my angular app, I went through a tutorial and even copied and pasted code to test the bootstrapping process, it didnt work. Can someone please tell me the simplest way to use angular.bootstrap() and to initialize my app with out using ng-app?

I am facing an issue with bootstrapping my angular app, I went through a tutorial and even copied and pasted code to test the bootstrapping process, it didnt work. Can someone please tell me the simplest way to use angular.bootstrap() and to initialize my app with out using ng-app?

Share edited Jul 1, 2014 at 7:42 Ch Faizan Mustansar 3643 gold badges6 silver badges19 bronze badges asked Oct 18, 2013 at 19:53 JesseJesse 8252 gold badges11 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Here's an example plunk: http://plnkr.co/edit/oScYFRsoCbXgpeuvN627?p=preview

The relevant bit is here (where 'test' is the name of my module):

angular.element(document).ready(function() {
  angular.bootstrap(document, ['test']);
});

Of course if you don't want to use the whole document (equivalent of putting ng-app on the tag), you could also use jquery to find the element you wanted:

$('mydiv').ready(function() {
  angular.bootstrap($('mydiv'), ['test']);
});

When I simple use

angular.bootstrap(documentGetElementById('mydiv'), ['test']);

html element is empty and this doesn't do any affect, but when use:

$('mydiv').ready(function() {});

div is exist and bootstrap work as well. All any different source say do simple: angular.bootstrap('html-element', ['some-module-name']); for me it isn't working.

发布评论

评论列表(0)

  1. 暂无评论