Answer the question
In order to leave comments, you need to log in
Working with NgStorage or equivalent from Angular module .factory or .config
Good day to all. Such is the question:
There is the following code, which, let's say, makes an add-on to Resctangular through factories.
The essence I need: after each request through Restangular, check the status of the code and perform actions with data in ngStorage
angular.module('app').factory('ApiV1Restangular', ['Restangular', function(Restangular) {
return Restangular.withConfig(function(RestangularConfigurer) {
RestangularConfigurer
.setBaseUrl('/api/v1/')
.setFullResponse(true)
.addResponseInterceptor(function(operation, what, url, deferred, response){
console.log(response.status);
if(response.status == 401){
window.location = '#/login'
}
});
});
}]);
Error: [$injector:unpr] .... и т д
Answer the question
In order to leave comments, you need to log in
What did you read and understand that $localStorage cannot be used in a factory?
@maxaon
And what, in this case, I have it wrong, with such a record?
angular.module('app').run(['$provide', '$compileProvider', '$locationProvider',
'$httpProvider', 'RestangularProvider', 'ngStorage',
function($provide, $compileProvider, $locationProvider, $httpProvider, RestangularProvider, $localStorage) {
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question