What is the difference between Angular Service and Factory?
Many people new to Angular will wonder what is the difference between an Angular Service and an Angular Factory, and when to use which. They look the same, they seem to work the same. What’s the difference?
From the Angular docs, we know that they are both Angular Providers (as are Angular Value and Angular Constant).
The screen shot from the Angular doc boils it down …
If you find yourself creating a factory just to “new” some object, then use service because it has a simpler syntax and it does the ‘new’ for you. Otherwise, just use factory. Service is just ‘syntactic sugar’ on factory.
Behind the scenes, service makes a call to factory, which in turn makes a call to provider.