【发布时间】:2017-04-13 02:43:58
【问题描述】:
我正在尝试实现一个 ConfigService 来检索项目中正确环境的正确配置。我目前遇到循环依赖
(index):28 Error: (SystemJS) Provider parse errors:
Cannot instantiate cyclic dependency! Http: in NgModule AppModule
Error: Provider parse errors:
在我看来,我已经探索了代码并且存在问题:
自定义Http
constructor(backend: XHRBackend, options: RequestOptions, public spinnerService: SpinnerService, public exceptionService: ExceptionService, public configService: ConfigService)
异常服务
constructor(private _notificationService: NotificationService, private _spinnerService: SpinnerService, private _configService: ConfigService, private _router: Router)
配置服务
constructor(private http: Http) {}
如您所见,我在此图中显示了一个循环依赖项(没有任何好的约定):
我现在的问题是,如何解决?我听说过Injector,但我不确定我是否真的可以在这种情况下使用它。
提前感谢您的回答。
【问题讨论】:
标签: angular typescript