angular-deferred-bootstrap
angular-deferred-bootstrap copied to clipboard
injecting service to 'onError'
How can I inject anything to the
onError: function (response, localStorageService) {
//delete token from storage
})
this is exactly what I need to do with my app but cant inject!
+1
+1
I think you can add an else if to the handleError function:
function handleError(error) {
addErrorClass();
if (isFunction(config.onError)) {
config.onError(error);
} else if (isArray(config.onError)) {
promises = [];
callResolveFn(config.onError, 'handleError');
$q.all(promises).then(handleResults, handleError);
}
}
Then, it may be possible to use:
onError: ['localStorageService', function (response, localStorageService) {
//delete token from storage
})
But be aware that it can perform an endless loop in your page if the error is being caused by localStorageService.