I try to call a JQuery sticky plugin from the following declaration, but nothing happen i have check with debug message it pass through the line and the sticky not appear. But its Ok when i call normally from somewhere else.
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);
});
};
});
The code above works fine after fixing $.sticky.clear()