为什么拦截器工厂在配置文件中请求失败?

时间:2016-01-21 00:33:21

标签: javascript angularjs angular-http-interceptors

我有下一个配置(index.js)来调用我的拦截器工厂。

23:59:59

我的文件夹和文件顺序:

id    created_at
1     2016-01-19 20:03:00
2     2016-01-19 11:12:05
3     2016-01-20 03:04:01

当我打电话给我的" InterceptorFactory"函数来自' ./ factory-inteceptor.js',我的控制台出现下一个错误:

angular.module('pasApp')
 .factory('InterceptorFactory',['$q','$location',require('./factory-interceptor.js')])
 .config(['$stateProvider','$urlRouterProvider', '$httpProvider','InterceptorFactory',require('./config-app.js')])
 .run(['$ionicPlatform','$rootScope','$window','StorageFactory','$state','$timeout','$http',require('./run-app.js')]);

2 个答案:

答案 0 :(得分:0)

确保factory-interceptor.js正在导出要注册的工厂的功能。

答案 1 :(得分:0)

配置块 - 在提供程序注册和配置阶段执行。只有提供程序和常量才能注入配置块。这是为了防止在完全配置服务之前意外实例化服务。

这样我就无法在配置块中注入工厂。在将配置块添加到应用程序之前,此工厂将被注入。

Angular documentation