| Really, Services and Factories are just a shorthand way of creating providers. .factory('foo', function() { var foo = {};
return foo;
});is the same as: .provider('foo', function() { this.$get = function() {
var foo = {};
return foo;
};
});And, .service('foo', function() { this.bar = 'bar';
});is the same as: .factory('foo', function() { function Foo() {
this.bar = 'bar';
}
return new Foo();
});is the same as: .provider('foo', function() { this.$get = function() {
function Foo() {
this.bar = 'bar';
}
return new Foo();
}
}); |
That said, I echo spion's comment, that all this confusion is a sign that the API could use a bit of cleaning.