Assume i've a route on my app like /config.json
which will return an object with settings like user currency, user locale, etc.
I would like to preload all of this values as soon as possible, and only one time, while the application is going up.
The app.config()
section would be good enough i think, but i cannot access the $http service at that time. How would you approach this?
EDIT
I'm adding this attempt to provide more context.
module.factory("test", function ($http) {
// This is the service. It depends on the
// settings, which must be read with a HTTP GET.
return service = {
settings: null,
get: function(value) {
return this.settings[ value ];
}
};
});
I've tried to return a deffered service instance, i.e.
return $http.get('/config').then(function(response){
service.settings = response.data;
return service;
});
but, apparently, it's not allowed to return a deferred service.