What is difference between factory service and provider in angularjs?



What is difference between factory service and provider in angularjs?..

Answer / Jitendra Verma

In AngularJS, both Factory and Provider are used for dependency injection but they differ in how they create instances of the services. n- Factory is a function that returns an object. It is called every time when the dependency is requested.n- Provider on the other hand is an object that can be configured before it is used to create a service instance.n- By default, a provider creates a new instance every time a service is needed. However, if you want to have one shared instance of a service across your application, you should use $provide.value() or $provide.service().

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

What is deep linking in angular 2?

1 Answers  


What is @injectable providedin root?

1 Answers  


What are the ways to track the error in angularjs?

1 Answers  


What is tap in angular?

1 Answers  


Explain validations done in angularjs?

1 Answers  


Is rxjs the same as react?

1 Answers  


What is routerlinkactive in angular?

1 Answers  


What is ngstyle and ngclass?

1 Answers  


What is routing and navigation in angular?

1 Answers  


How to create a service in angularjs?

1 Answers  


Explain directives? What are inbuilt directives available in angularjs?

1 Answers  


What is the bootstrapping in AngularJS?

1 Answers  


Categories