我尝试从以下声明调用一个JQuery粘性插件,但没有任何反应我检查它通过该行的调试消息并且粘贴不出现。但是,当我从其他地方正常打电话时,它就OK了。
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);
});
};
});
答案 0 :(得分:0)
修复$ .sticky.clear()
后,上面的代码运行正常