在我的script.js中,如果没有ajax调用,我必须重定向到登录页面,但我有response.status = 200!
myapp.factory('myHttpResponseInterceptor',['$q','$location',function($q,$location){
return {
response: function(response) {
return response;
}, responseError: function(response) {
if (response.status === 401)
$location.url('/login');
return $q.reject(response);
}
}
}]);
myapp.config(['$httpProvider',function($httpProvider) {
$httpProvider.interceptors.push('myHttpResponseInterceptor');
}]);