For me the revelation came when I realised that they all work the same way: by running something once, storing the value they get, and then cough up that same stored value when referenced through Dependency Injection.
Say we have:
app.factory('a', fn); app.service('b', fn); app.provider('c', fn);
The difference between the three is that:
a's stored value comes from running
b's stored value comes from
c's stored value comes from first getting an instance by
fn, and then running a
$getmethod of the instance
which means, there’s something like a cache object inside angular, whose value of each injection is only assigned once, when they’ve been injected the first time, and where:
cache.a = fn() cache.b = new fn() cache.c = (new fn()).$get()
This is why we use
this in services, and define a
this.$get in providers.