После нескольких поисков я нашел ответ. Вы должны написать фильтр и ввести это в http
$httpProvider.interceptors.push('myHttpInterceptor');
Пожалуйста, найдите полный код
angular.module("app").config(['$httpProvider', function ($httpProvider) {
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
$httpProvider.interceptors.push('myHttpInterceptor');
}
else {
}
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}
]);
angular.module('app').factory('myHttpInterceptor', function ($q) {
return {
// optional method
'request': function (config) {
debugger;
return config;
},
// optional method
'requestError': function (rejection) {
// do something on error
return $q.reject(rejection);
},
// optional method
'response': function (response) {
// do something on success
return response;
},
// optional method
'responseError': function (rejection) {
// do something on error
return $q.reject(rejection);
}
};
});