Foysal Vai
Foysal Vai

Reputation: 1363

AngularJS Documentation of .run() function

I am working with angularJS routing. In this regard I need documentation of .run() function.What is the responsibility of .run() function.Thanks

Upvotes: 0

Views: 24

Answers (1)

Joe Enzminger
Joe Enzminger

Reputation: 11190

From the docs

Run Blocks

Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the services have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.

run() is also the earliest you will have access to $rootScope. It is a good place to register states and routes.

Upvotes: 2

Related Questions