I get questo errore per motivi sconosciuti durante il tentativo di implementare un codice di caricamento AJAX Spinner.AngularJS Interceptor TypeError: Impossibile leggere le intestazioni della proprietà di undefined
Non capisco dove si debba definire l'intestazione. Ho fatto console.log(config)
ma posso vedere il valore headers: accept: text/html
lì.
Qui di seguito è il mio codice:
/**
* Spinner Service
*/
//Spinner Constants
diary.constant('START_REQUEST','START_REQUEST');
diary.constant('END_REQUEST','END_REQUEST');
//Register the interceptor service
diary.factory('ajaxInterceptor', ['$injector','START_REQUEST', 'END_REQUEST', function ($injector, START_REQUEST, END_REQUEST) {
var $http,
$rootScope,
myAjaxInterceptor = {
request: function (config) {
$http = $http || $injector.get('$http');
if ($http.pendingRequests.length < 1) {
console.log(config);
$rootScope = $rootScope || $injector.get('$rootScope');
$rootScope.$broadcast(START_REQUEST);
}
}
};
return myAjaxInterceptor;
}]);
diary.config(['$httpProvider', function ($httpProvider) {
$httpProvider.interceptors.push('ajaxInterceptor');
}]);
su quale linea si ottiene questo errore? – Grundy
No Line Number è spettacolo di angolare ::: ====== TypeError: Impossibile leggere proprietà 'headers' di indefinito a $ get.serverRequest (angular.js: 9366) a processQueue (angular.js: 13248) in angular.js: 13264 in Scope. $ Get.Scope. $ Eval (angular.js: 14466) in Scope. $ Get.Scope. $ Digest (angular.js: 14282) in Scope. $ get.Scope. $ apply (angular.js: 14571) in bootstrapApply (angular.js: 1455) in Object.invoke (angular.js: 4203) in doBootstrap (angular.js: 1453) all'avvio (angolare .js: 1473) – ChanX