Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ng-app wait for document.ready?

I've got a small ng-app/ng-controller block inside a large HTML file. I thought ng-app would be triggered after its div is loaded but in my case it waits for document.ready event.

When does angular instantiate ng-app?

like image 840
fedor.belov Avatar asked Mar 31 '15 13:03

fedor.belov


People also ask

Can we have two ng-app?

Only one ngApp directive can be auto-bootloaded per HTML Document but you can have multiple apps as long as you manually bootstrap the subsequent ones.

Can we Nest ng-app?

You can't use one ng-app inside another one in angularjs. because AngularJS applications cannot be nested within each other.


1 Answers

No, it waits for DOM content to load. See the diagram from this documentation https://docs.angularjs.org/guide/bootstrap.

enter image description here

You can wait for dom ready with ready().

angular.module("Foo")
  .controller("Bar", function () {
    angular.element(document).ready(function () {
    });
});
like image 149
Steven Wexler Avatar answered Oct 12 '22 22:10

Steven Wexler