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.

Getting "No component factory" error while opening a Material Dialog in lazy loaded Component

See original GitHub issue

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"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

16reactions
jelbourncommented, Nov 21, 2017

You need to import MatDialogModule in ConsumerModule in order for it to know about the entryComponents there

12reactions
travtarrcommented, Aug 23, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular : Getting "No component factory" error while opening ...
The module that contain ConfirmBoxComponent is loaded via Lazy loading technique. I'm using latest version of Angular and Material. "@angular/ ...
Read more >
Angular Dynamic Components: Building a Dialog System
To get started, let's create an empty dialog component. This component will consist of a white dialog area, while the rest of the...
Read more >
Lazy-load a component in Angular without routing
One of the most seeking features in Angular is to lazy load a component when you need it. It is a very straightforward...
Read more >
No component factory found for... Opening a Modal-angular.js
For opening a component in a modal, you have to add the component in the app.module.js as a entryComponent . Your error message...
Read more >
angular/material2 - Gitter
Loading @angular/material/bundles/material.umd.js ... I am getting this error. ERROR Error: No component factory found for DialogCreatePickupComponent.
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