What is the best place to store application configuration settings in AngularJS? This could be things like application constants, lookups etc. which could be used both from cont
Define:
angular.module('starter.config', [])
.constant('appConfig', {
'backend': 'http://localhost:3000/v1'
});
Usage:
angular.module('starter.services', ['starter.config'])
.factory('Locations', function(appConfig, $http) {
return {
all: function(successCb, errorCb) {
$http.get(appConfig.backend + '/locations.json')
.success(successCb)
.error(errorCb);
},
get: function(locationId, successCb, errorCb) {
$http.get(appConfig.backend + '/locations/'+ locationId +'.json')
.success(successCb)
.error(errorCb);
}
};
})