我尝试从以下声明中调用 JQuery 粘性插件,但没有任何反应,我检查了调试消息,它通过了线路并且粘性没有出现。但是当我从其他地方正常打电话时,它就可以了。
var globalService = angular.module('global.service', []);
globalService.config(function ($httpProvider) {
$httpProvider.responseInterceptors.push('myHttpInterceptor');
var spinnerFunction = function (data, headersGetter) {
var settings = {
'speed' : 'fast',
'duplicates' : false,
'autoclose' : false
};
$.sticky('Loading..', settings);
return data;
};
$httpProvider.defaults.transformRequest.push(spinnerFunction);
});
//register the interceptor as a service, intercepts ALL angular ajax http calls
globalService.factory('myHttpInterceptor', function ($q, $window) {
return function (promise) {
return promise.then(function (response) {
// do something on success
// todo hide the spinner
$.sticky.clear();
return response;
}, function (response) {
// do something on error
// todo hide the spinner
$.sticky.clear();
return $q.reject(response);
});
};
});