What is the difference between Factory, Service and Provider?

Answer Posted / chaitanya

Factory - A factory is a simple function which allows you to add some logic before creating the object. It returns the created object.

Service - A service is a constructor function which creates the object using new keyword. You can add properties and functions to a service object by using this keyword. Unlike factory, it doesn’t return anything.

Provider - A provider is used to create a configurable service object. It returns value by using $get() function.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain ng-click directive?

432


In collection of array how to collect all the true state from active true and active false?

439


Explain why there are two “destroy” events associated with the termination of scope in angularjs?

653


Difference between directive and pipe in angular?

440


What is ng-cloak directive and why we use?

455






How would you optimize the angular 2 application for better performance?

425


What are the advantages of token-based authentication?

455


List at down the ways in which you can communicate between applications modules using core angular functionality.

406


How to catch and log specific angular errors in your app?

413


What is difference between ng if and ng show?

399


What is ng init?

387


Which is better react or angular?

418


How $location is different from window.location in angularjs?

412


Is angularjs extensible?

483


What are $scope in angular js?

427