I have the following code:
function configRestangular(RestangularProvider, BASE_URL) {
RestangularProvider.setBaseUrl(BASE_URL);
RestangularProvider.setDefaultHeaders({ 'Content-Type': 'application/json' });
RestangularProvider.setErrorInterceptor(
function (response, deferred) {
if (response.status === 401 || response.status === 403) {
//$state.go('login');
}
});
}
core.config(configRestangular);
When I pass $localStorage to function configRestangular(RestangularProvider, BASE_URL), application throws an exception.
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:modulerr] Failed to instantiate module app.core due to: Error: [$injector:unpr] Unknown provider: $localStorage http://errors.angularjs.org/1.4.0-rc.2/$injector/unpr?p0=%24localStorage
I have registered the ngStorage module in main module. ngStorage.js file is also added in my main page. $localStorage service is working in all controllers except this config function.
I am using https://github.com/gsklee/ngStorage module for localStorage.