When to use factory?



When to use factory?..

Answer / Ashish Gotra

Factories in AngularJS are used to create new services, and they can be used when you need to return an object or a function. They are useful when you need more control over the instantiation process compared to services. For example, if you have a complex service that requires multiple dependencies, a factory can be used to configure these dependencies.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AngularJS Interview Questions

Explain call and apply method?

1 Answers  


What is ivy rendering engine in angular 7?

1 Answers  


What are inbuilt directives available in angularjs?

1 Answers  


What is the main purpose of $routeprovider in angularjs?

1 Answers  


Which database is best for angularjs?

1 Answers  


what is di (dependency injection)?

1 Answers  


Write the cli command to generate a component in angular 4?

1 Answers  


Why do we need provider aliases? And how do you create one?

1 Answers  


What is a selector?

1 Answers  


What is pure and impure pipes? When to use pure and impure pipes?

1 Answers  


What are the modules in angularjs?

1 Answers  


Is angular 7 a framework?

1 Answers  


Categories