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?
2 Answers
Reset to default 9Here'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.