AngularJS$http拦截器
Javascript代码AngularJS$http拦截器,angularjs,Angularjs,Javascript代码 commonApp = angular.module('commonApp') .config(function($httpProvider){ $httpProvider.interceptors.push('myHttpInterceptor'); }) .factory('myHttpInterceptor', function($q, $window){ return { request: func
commonApp = angular.module('commonApp')
.config(function($httpProvider){
$httpProvider.interceptors.push('myHttpInterceptor');
})
.factory('myHttpInterceptor', function($q, $window){
return {
request: function(config){
console.log('Request started'); // LOG AT REQUEST START
return config || $q.when(config);
}
};
});
我认为应该在xhr请求开始时记录该消息。
但我看到的日志没有xhr请求
我是不是误解了api 您的plunkr似乎工作正常?关于理解角度http拦截器,您可能会发现有一篇很好的博文很有用:Plunkr显示了问题所在