Bug: Cyclic dependencies while opening modal from service with App_Initializer
See original GitHub issueIt seems having NgbModal
reference in service is causing cyclic dependency error with App_Initializer
.
Checkout this plunker: http://plnkr.co/edit/FIj4tMjUikbGHIHhf7ko?p=preview
Remove the following code from the plunker and the modal would be displayed as expected from the service.
{
provide: APP_INITIALIZER,
useFactory: initializeServiceFactory,
deps: [InitializeService],
multi: true
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Bug: Cyclic dependencies while opening modal from service with ...
It seems having NgbModal reference in service is causing cyclic dependency error with App_Initializer .
Read more >Angular 9 Cannot instantiate cyclic dependency! ApplicationRef
I find this solution: Not to inject directly in the constructor the NgModal, through of the Injector: private modalService: NgbModal ...
Read more >NG0200: Circular dependency in DI detected while ... - Angular
A cyclic dependency exists when a dependency of a service directly or indirectly depends on the service itself. For example, if UserService depends...
Read more >Feb 06 2018 01:04 UTC - angular/angular - Gitter
Uncaught Error: Provider parse errors: Cannot instantiate cyclic dependency! ApplicationRef ("[ERROR ->]"): in NgModule AppModule in .
Read more >[Solved]-Angular 8: Cannot instantiate cyclic dependency
This is happening due to a loop in dependency injection, for example you have injected a service into itself in its constructor! Qiimiia...
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
Yes, this is what I would suggest as a work-around.
I don’t think we can make it work from
APP_INITIALIZER
in the current Angular - it is very early in the initialisation process and all the modal-required infrastructure is not ready yet.