3

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 2

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']);
});
1
  • Can a similar action be implemented using things like ng-show and hide? I wanted to do something like apply an ng-show to an element that has a directive attached to it? with out having to go and write it, I tried actually using jquery's .attr feature to do it but it did not work.
    – Jesse
    Oct 18, 2013 at 20:34
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.