What is difference between config() and run() method in AngularJS?

Answer Posted / chaitanya

Configuration block – This block is executed during the provider registration and configuration phase. Only providers and constants can be injected into configuration blocks. This block is used to inject module wise configuration settings to prevent accidental instantiation of services before they have been fully configured. This block is created using config() method.

Run block – This block is executed after the configuration block. It is used to inject instances and constants. This block is created using run() method. This method is like as main method in C or C++. The run block is a great place to put event handlers that need to be executed at the root level for the application. For example, authentication handlers.

Is This Answer Correct ?    54 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain ng-repeat directive ?

403


When to use factory?

488


What is called in angular?

403


When will nginit be called? How would you make use of ngoninit()?

440


What is cdk in angular?

398






What is event distner and host distner in angular?

431


What is the use of a filter?

426


Explain ng-controller directive ?

463


What is shadow dom in angular?

424


What is the difference between ajax and angularjs?

435


What is angular controllers?

447


What is the difference between angular and react?

430


How to get image width height in angular js, before uploading a file?

467


What is dependency injection in angular?

446


What is observable and promise?

422