Angularjs Calling Order

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.