Hi,
Im getting the following error when i try to open Material Dialog in ConfirmBoxComponent
.
No component factory found for ConfirmBoxComponent. Did you add it to @NgModule.entryComponents?
I have already added ConfirmBoxComponent in entryComponents list
declarations: [
ConfirmBoxComponent
],
exports: [ConfirmBoxComponent],
entryComponents: [
ConfirmBoxComponent
],
The module that contain ConfirmBoxComponent is loaded via Lazy loading technique.
I'm not sure this is bug or not.
I'm using latest version of Angular and Material
"@angular/core": "^5.0.0",
"@angular/material": "^5.0.0-rc0"
Have you checked #1491?
Ya . But its not working for me .
I have added ConfirmBoxComponent in entry components of my lazy loaded Module. But i'm still getting that error.
here is my code ( Not complete code)
https://gist.github.com/nithindan/f1a027e4b8589c59af9ec763b0ffded8
Can you please share your entire NgModule setup?
@jelbourn Is there any way to fix this ?
You need to import MatDialogModule
in ConsumerModule
in order for it to know about the entryComponents
there
thanks a lot @jelbourn . it worked <3
Is this still the solution for this issue? Or has something else changed as of late?
I can't seam to get this to work, this is basically the exact same setup I got, but only getting:
No component factory found for LoginDialogComponent
In regards to Angular v6+: in case anyone is using the MatDialog
service inside another injectable service and is using the { providedIn: 'root' }
option for that service, you'll need to instead provide that service in the providers
array of the module where your dialog components are declared.
@travtarr thanks so much for the answer.... I had that exact same issue.
Plus it also only started working after i killed off ng serve
In short: If you the service building your component is only provided in root
, be sure to also provide it in the lazy loaded module!
Why does that need to be like this though?
@travtarr "you'll need to instead provide that service in the providers array of the module where your dialog components are declared." this will declare a new instance of the service so it's not possible to have a singleton in the app to launch dialog ?
@jingignoli I didn't clarify in my original post, but you'll want to remove the providedIn: 'root'
when you provide it in a module.
@travtarr Thanks for your answer but the service will be scoped to the module.
I need a singleton in my app to control my modals.
@jingignoli Then you'll probably need to place your modal component declarations in a non-lazy-loaded module to avoid this issue.
@travtarr this is not a solution for me :(
My application is really huge and i have to isolate and lazy load feature module.
My modals are really feature centric and need component from the feature module so this force me to load the entire module.
Btw, thanks for your time :)
@jingignoli have you addressed this issue? I have same issue as yours :(
@min-w-park no i haven't created an issue for this, i don't know if it's a bug or a normal behavior.
I have the same question about it锛學hen I open lazyload module.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You need to import
MatDialogModule
inConsumerModule
in order for it to know about theentryComponents
there