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();
}
});
.factory('foo', function() {
});is the same as:
.provider('foo', function() {
});And,
.service('foo', function() {
});is the same as:
.factory('foo', function() {
});is the same as:
.provider('foo', function() {
});