Deepak Ingole
Deepak Ingole

Reputation: 15772

AngularJS module lifecycle

Just googling "AngularJS Module Lifecycle". Could not find anything interesting. Can anybody on the explain me this.

I want to understand how exactly

angular.module("ui.bootstrap", [
    "ui.bootstrap.tpls", 
    "ui.bootstrap.accordion"
]);
  1. How exactly the dependencies gets resolved & in which order they gets loaded.?
  2. Does angular first calls run phase for ui.bootstrap then calls config and then loads dependencies?
  3. (When) Does angular also calls run and config phase for all dependent modules?

Upvotes: 3

Views: 3127

Answers (1)

Romski
Romski

Reputation: 1942

From the documentation

  • The modules can be loaded in any order
  • Configuration blocks - get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured.
  • Run blocks - get executed after the injector is created and are used to kickstart the application. Only instances and constants can be injected into run blocks. This is to prevent further system configuration during application run time.

EDIT - update link

Upvotes: 2

Related Questions