Skip to content Skip to sidebar Skip to footer

How Does Document.ready Work With Angular Element Directives?

In my current project I'm using angular directives to create custom html elements. See example below. banner.js app.directive('banner', function () { return { restric

Solution 1:

This is less a "directives" question, and more an Angular sequence of events question.

Angular itself (if not manually started with .bootstrap) will defer its loading until .onready.

At that point in time, Angular expects that all JS it needs to run will be there and registered.

Then Angular starts up. Then after Angular starts up, Angular parses the DOM to find a root element to attach to (the one with the ng-app directive).

Then it recursively goes down the line, injecting controllers and building out directives and interpolating nodes as it goes.

Now we are way past any code that would have fired on DOMReady.

Post a Comment for "How Does Document.ready Work With Angular Element Directives?"