gpt4 book ai didi

angular - NG0200 : Circular dependency in DI detected for ApplicationRef

转载 作者:行者123 更新时间:2023-12-05 05:56:01 27 4
gpt4 key购买 nike

重构应用程序时出现以下错误:

main.ts:21 Error: NG0200: Circular dependency in DI detected for ApplicationRef. Find more at https://angular.io/errors/NG0200
at throwCyclicDependencyError (core.js:216)
at R3Injector.hydrate (core.js:11433)
at R3Injector.get (core.js:11256)
at injectInjectorOnly (core.js:4751)
at Module.ɵɵinject (core.js:4755)
at Object.Config_Factory [as factory] (config.ts:7)
at R3Injector.hydrate (core.js:11437)
at R3Injector.get (core.js:11256)
at injectInjectorOnly (core.js:4751)
at Module.ɵɵinject (core.js:4755)

但是我还没有发现任何循环依赖。还有什么原因?

最佳答案

这是由于向 ErrorHandler 中注入(inject)自定义服务引起的:

@Injectable()
export class GlobalErrorHandler extends ErrorHandler {
/*constructor(protected readonly customService: CustomService) {
super();
}*/
}

似乎只有 Angular 的服务(如 HttpClient)可以注入(inject)到那里。

关于angular - NG0200 : Circular dependency in DI detected for ApplicationRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69311308/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com