October 2017
Intermediate to advanced
280 pages
6h 50m
English
Services are the building blocks that Angular provides for the definition of the business logic of our applications. In AngularJS, we had three different ways of defining services:
// The Factory method
module.factory('ServiceName', function (dep1, dep2, ...) {
return {
// public API
};
});
// The Service method
module.service('ServiceName', function (dep1, dep2, ...) {
// public API
this.publicProp = val;
});
// The Provider method
module.provider('ServiceName', function () {
return {
$get: function (dep1, dep2, ...) {
return {
// public API
};
}
};
});
Although the first two syntactical variations provide similar functionality, they differ in the way the registered service will be instantiated. The third syntax allows further ...
Read now
Unlock full access