AngularJS拦截$http请求
$httpProvider.interceptors.push(['$q',function ($q) {
return {
request: function (config) {
if(config.url==='/admin.php') {
return $q.reject('no auth!');
}
return config;
},
responseError: function(rejection) {
if(rejection==='no auth!') {
alert('无权限!!!');
return {
data: {
errno: -1,
error:'无权限'
}
}
}
return $q.reject(rejection);
}
}
}]);