question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Cyclic dependencies while opening modal from service with App_Initializer

See original GitHub issue

It 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pkozlowski-opensourcecommented, Jan 26, 2018

Wonder if this is good temporary fix for the issue.

Yes, this is what I would suggest as a work-around.

0reactions
pkozlowski-opensourcecommented, Sep 22, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found