adspace


What is the difference between factory and service in angularjs?

Answer Posted / Dilbagh Singh

Factory and Service are both used for dependency injection in AngularJS, but they differ in their usage. A factory returns a new object each time it is invoked, while a service returns a singleton instance (a single instance shared across the entire application). Factory can be useful when you need to create complex objects that require multiple functions or properties.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to create angularjs filter which outputs html?

860


How to enable html5 mode in angular 1.x?

927


Angularjs dependency injection of value inside of the module.config?

895


How to use primeng in angular 4?

948


What is the latest version of angular?

979


What is the latest angular?

809


How to get and log an error in angular 4?

876


How an object or function can get a hold of its dependencies?

854


What is a dynamic route in angularjs and how do you implement it?

864


How to implement a datagrid table with angular 2 and primeng?

892


Give the example of angularjs strings?

876


Which version you are using js?

946


How can primeng be used with angular2?

946