我正在使用拦截器来加载微调器,这很棒。但是,我想从显示微调器中排除特定的http请求url。任何可能的想法如何解决此问题?
控制器
$rootScope.$on('loading:progress', function (config){
$scope.spinner=true;
});
$rootScope.$on('loading:finish', function (){
$scope.spinner=false;
});
工厂/配置
app.factory('httpInterceptor', ['$q', '$rootScope',
function ($q, $rootScope) {
var loadingCount = 0;
return {
request: function (config) {
if(++loadingCount === 1)
$rootScope.$broadcast('loading:progress');
return config || $q.when(config);
},
response: function (response) {
if(--loadingCount === 0) $rootScope.$broadcast('loading:finish');
return response || $q.when(response);
},
responseError: function (response) {
if(--loadingCount === 0) $rootScope.$broadcast('loading:finish');
return $q.reject(response);
}
};
}]).config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push('httpInterceptor');}]);