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



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

Answer / 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

More AngularJS Interview Questions

Explain the difference between angular and angularjs?

0 Answers  


How does the $resource `get` function work synchronously in angularjs ?

0 Answers  


What do you mean by module?

0 Answers  


What is difference between component and module in angular?

0 Answers  


How would you use an angular service to pass data between controllers? Explain with examples?

0 Answers  






What is routing in javascript?

0 Answers  


What are the benefits of dependency injection?

0 Answers  


How do we display errors in a component view with angular 2?

0 Answers  


Explain the concept of lazy loading in angular 2

0 Answers  


What are major changes in angular 2?

0 Answers  


What’s the difference between http and httpclient?

0 Answers  


How can we share data between controllers?

0 Answers  


Categories