I have written a module in angularJS that encapsulates all the backend communications. For greater flexibility I have the api prefix as a constant value on the module (could be
to override the module values, you can redefine the angular value in later modules. I believe it should not be done module config time.
angular.module("data", [])
.value('apiPrefix', '/api/data')
.factory('Display', function(apiPrefix){
return {
pref: function(){
return apiPrefix;
}
}
});
angular.module('myapp', ['data'])
.value('apiPrefix', '/api2/data')
.controller('MainCtrl', function($scope, Display) {
$scope.name = Display.pref();
});
see the plunker here: http://plnkr.co/edit/k806WE
same thing is applicable for angular constants too.