AngularJS Services Part 4: Value and Constant

So far we saw the magic of creating AngularJS services using Provider, Factory and Service. In this post, we will look at two more types of services - Value and Constant. Value The Value service is basically a service that returns a single value, like, string, object, number or an array. For instance: (function(){ angular.module('app', []) .value("Number", 24) .value("String", "Hey, how are you?") .value("Object", { prop1: 'prop1', prop2: 'prop2' }) ....

March 1, 2015 · 2 min · Ilija