As I understand it, when inside a factory I return an object that gets injected into a controller. When inside a service I am dealing with the object using this
All providers work the same way. The different methods service
, factory
, provider
just let you accomplish the same thing in less code.
P.S. There's also value
and constant
.
Each special case down the chain starting with provider
and ending with value
has an added limitation. So to decide between them you have to ask yourself which let's you accomplish what you want with less code.
Here is a picture that shows you what I mean:
You can a breakdown and reference guide on the blog post I got this image from:
http://www.simplygoodcode.com/2015/11/the-difference-between-service-provider-and-factory-in-angularjs/