DEV Community

Discussion on: Manually Lazy load Components in Angular 8

Collapse
 
benifreitag profile image
Benjamin Freitag • Edited

Do you know how to get it to work with a Material Dialog instead of a viewcontainer, like this?

this.lazyLoader.load("lazy").then(res => {
      this.dialog.open(res.componentType)
    })
Enter fullscreen mode Exit fullscreen mode

I extended your sample at stackblitz.com/edit/lazy-angular-d... but also recieve Error: No component factory found for LazyComponent. Did you add it to @NgModule.entryComponents?

Collapse
 
binarysort profile image
Mayank Dubey

Hi,

Have you tried providing alternate componentFactoryResolver in material dialog config?

Collapse
 
benifreitag profile image
Benjamin Freitag • Edited

Thanks. Yes, I tried this but it still causes the same error in Angular 8. I updated the Stackblitz.

In Angular 9 this is fixed and there's no need to pass componentFactoryResolver 👏

Thread Thread
 
binarysort profile image
Mayank Dubey

I think it's related to this issue github.com/angular/angular/issues/...

Some comments have been hidden by the post's author - find out more