MatDialog: cyclic dependency when using MatDialog in a HTTP_INTERCEPTORS
See original GitHub issueBug (or odd edge case):
I use MatDialog
in a HTTP_INTERCEPTORS
to display a dialog if the HttpClient
responds with a 401
. This start causing “cyclic dependency” errors when HttpClient
is a dependency for APP_INITIALIZER
.
What is the expected behavior?
No “cyclic dependency” errors.
What is the current behavior?
This might happen due to the Overlay
(used in MatDialog
constructor) injecting the ApplicationRef
that’s already imported by ApplicationModule
. This error is thrown during resolving of deps for APP_INITIALIZER
.
What are the steps to reproduce?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Circular Dependancy in Angular-Material Dialog Module
Both modals are opened from the authService. The problem is that the authService needs a reference to the login and signup components in...
Read more >[Solved]-Cannot instantiate cyclic dependency ...
Coding example for the question Cannot instantiate cyclic dependency! HTTP_INTERCEPTORS ("[ERROR ->]"): in NgModule CoreModule-rx.js.
Read more >Services, Interceptors, and Cyclic Dependencies : r/angular
I've fallen into the mud of some cyclic dependency that has to do with HttpInterceptors and can't figure out how to work around...
Read more >Angular 4: Cannot Instantiate Cyclic Dependency ... - ADocLib
core js circular dependency If you use predominantly constructor ... create cyclic dependency, there should be service from inside Angular HttpInterceptor I ...
Read more >NG0200: Circular dependency in DI detected while ... - Angular
Debugging the errorlink. Use the call stack to determine where the cyclical dependency exists. You will be able to see if any child...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should be able to do something like this:
Closing as a dupe of https://github.com/angular/material2/issues/10967 which will be fixed by https://github.com/angular/material2/pull/10975.