Here ' s The calling order:
App. Config ()
App.run ()
Directive ' s compile functions (if they is found in the DOM)
App.controller ()
Directive ' s link functions (again if found)
Here's a simple demo where can watch each of the Execute (and experiment if you ' d like).
From Angular ' s module docs:
Run Blocks-get executed after the injector is created and be used to kickstart the application. Only instances and constants can is injected into run blocks. This was to prevent further system configuration during application run time.
Run blocks is the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It was executed after all of the service had been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should are declared in isolated modules, So, they can ignored in the unit-tests.
One place to see run blocks used are for authentication
Angularjs Calling Order