Home > Net >  Angular : Getting "No component factory" error while opening a Material Dialog in lazy loa
Angular : Getting "No component factory" error while opening a Material Dialog in lazy loa

Time:02-03

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 using latest version of Angular and Material

"@angular/core": "^5.0.0", "@angular/material": "^5.0.0-rc0"

CodePudding user response:

In my case, I imported MatDialogModule into my lazy loaded module, but still used MatDialog instance from root module, because MatDialog was injected into my own DialogService, which is provided in root module. When I use correct MatDialog instance, from lazy loaded module, there is no error.

CodePudding user response:

This is fixed. I forgot to import MatDialogModule in my lazy loaded module.

  • Related