0
我想寫一個$ httpProvider攔截器工廠,但遇到問題,我認爲它與工廠語法。在配置函數中添加工廠作爲依賴項時,錯誤是'無法實例化模塊...'。導出AngularJS工廠
所以我的問題是如何編寫一個可以導出到配置功能的攔截器工廠?
// Factory
export class GlinterceptorFactory {
constructor ($http, $q, $rootScope, $log) {
'ngInject';
this.$http = $http;
this.$q = $q;
this.$rootScope = $rootScope;
this.$log = $log;
}
request(config) {
return this.$log.log('request config factory: ', config);
}
}
// Config function.
export function config ($logProvider, $httpProvider, glinterceptor) {
'ngInject';
$logProvider.debugEnabled(true);
console.log(glinterceptor);
//$httpProvider.interceptors.push(glinterceptor);
}
// Module js.
import { config } from './index.config';
import { GlinterceptorFactory } from '../app/components/factories/glinterceptor.factory';
angular.module('ui', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'ngMap', 'chart.js', 'angular-carousel'])
.config(config)
.config(routerConfig)
.run(runBlock)
... more
.factory('glinterceptor', GlinterceptorFactory)
... more