The Value service is basically a service that returns a single value, like, string, object, number or an array. For instance:
The Value service is basically like writing a service using Provider, whose $get function returns a plain value (string/object/number/array).
If you are unfamiliar of the way Provider works, take a look here. One drawback of Value is that it cannot be injected into a module configuration function, unlike Provider. On the other hand, it can be decorated using an Angular decorator.
The Constant service is really the same like Value, with two key differences:
- It can be injected into a module configuration function, like Provider.
- A Constant service cannot be decorated using an Angular decorator.
For consistency’s sake, lets see how constants are defined:
One last note - injecting Value and Constant services in controllers is done just like any other services.