Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see angular.Module) and it cannot be overridden by an Angular decorator.
angular.module('example').constant('config', {foo: 'bar'});
angular.module('example', [])
.provider('MyService', function ($logProvider){
var var1, var2;
this.setVar1 = function(value){ var1 = value; };
this.setVar2 = function(value){ var2 = value; };
this.$get = function ($q){
return new MyService();
function MyService(){
this.returnSomething = function (){
return $q.when('something ' + var1);
};
}
};
});