December 2014
Intermediate to advanced
346 pages
6h 14m
English
AngularJS service types, at their core, are singleton containers used for unified resource access across your application. Sometimes, the resource access will just be a single JS object. For this, AngularJS offers service values and service constants.
Service values and service constants both act in a very similar way, but with one important difference.
The service value is the simplest of all service types. The value service acts as a key-value pair and can be injected and used as follows:
(app.js)
angular.module('myApp', [])
.controller('Ctrl', function($scope, MyValue) {
$scope.data = MyValue;
$scope.update = function() {
MyValue.name = 'Brandon Marshall';
};
})
.value('MyValue', {Read now
Unlock full access