Open Triplecorpse opened 3 years ago
+1
+1
You can break the dependency circle by changing HttpLoaderFactory dependency from HttpClient into HttpBackend and by creating new HttpClient.
export function HttpLoaderFactory(httpHandler: HttpBackend) {
return new TranslateHttpLoader(new HttpClient(httpHandler));
}
// ... TranslateModule.forRoot ...
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpBackend] // ←
},
You can break the dependency circle by changing HttpLoaderFactory dependency from HttpClient into HttpBackend and by creating new HttpClient.
export function HttpLoaderFactory(httpHandler: HttpBackend) { return new TranslateHttpLoader(new HttpClient(httpHandler)); } // ... TranslateModule.forRoot ... loader: { provide: TranslateLoader, useFactory: HttpLoaderFactory, deps: [HttpBackend] // ← },
This saved my life..Thanks.
Hi. I am not sure if this issue was risen. At least, I googled it and found no solution. My app causes Circular dependency when I inject translateService into http interceptor. I googled it and found it's because of HttpClient dependency. The only working solution was to inject Injector and load TranslateService with it. Nevertheless, the error still occurred but the app worked as supposed. Is it any solution for that?