Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS:加载问题_Angularjs_Spring - Fatal编程技术网

AngularJS:加载问题

AngularJS:加载问题,angularjs,spring,Angularjs,Spring,获取错误未捕获错误:[$injector:cdep]在Angularjs服务加载中 下面是service.js App.factory'myHttpInterceptor',['Service',functionService{ var myHttpInterceptor={ 请求:functionconfig{ 如果!Service.isAnonymus{ config.headers['X-CSRFToken']=Service.token; } 返回配置; } }; 返回myHttpInt

获取错误未捕获错误:[$injector:cdep]在Angularjs服务加载中

下面是service.js

App.factory'myHttpInterceptor',['Service',functionService{ var myHttpInterceptor={ 请求:functionconfig{ 如果!Service.isAnonymus{ config.headers['X-CSRFToken']=Service.token; } 返回配置; } }; 返回myHttpInterceptor; }]; App.config['$httpProvider',函数$httpProvider{ $httpProvider.interceptors.push'myHttpInterceptor'; }];
****Solution**:**



App.factory('csrfResponseInterceptor', [function () {
    return{
        response: function(response){
            console.log(response.headers('X-CSRF-TOKEN'));
            return response;
        }
    }
}]);

App.config(['$httpProvider', function($httpProvider) {
    $httpProvider.defaults.xsrfHeaderName = 'X-CSRF-TOKEN';
    $httpProvider.interceptors.push(function() {
        return {
            response: function(response) {
                $httpProvider.defaults.headers.common['X-CSRF-TOKEN'] = response.headers('X-CSRF-TOKEN');
                return response;
            }
        }    
    });
}]);