繁体   English   中英

AngularJS $ http拦截器

[英]AngularJS $http interceptors

JavaScript代码...

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请求的日志。

Chrome Dev Tools屏幕截图

我误会了api吗?

你的朋克似乎还好吗? 关于理解有角度的http拦截器,有一篇不错的博客文章,您可能会发现它很有用: http : //djds4rce.wordpress.com/2013/08/13/understanding-angular-http-interceptors/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM