Defining a constant Service

The constant service is basically the same as the value service, except that constant services are available in the configuration phase of building the Module object, whereas value services are not. The constant method uses the following syntax, where name is the service name and object is any JavaScript object you want to provide:

constant(name, object)

For example:

var app = angular.module('myApp', []);app.constant('myConst', "Constant String");

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.