Error: No component factory found for DynamicDialogComponent. Did you add it to @NgModule.entryComponents

UI Components for Angular
Post Reply
Withnail73
Posts: 5
Joined: 01 Nov 2019, 18:32

23 Feb 2021, 19:10

Hey there. This is a weird one. I have application that was written in Angular 8 using Prime 8 - it's been running fine for more than a year now.

I have just migrated the Angular to 11, but can't afford to do the same to the Prime at the moment since it would be too much work to adjust the look and feel changes. So that's still on 8. Everything appears to work fine except the modal dialogs that have embedded components. As soon as the DialogService.open() is triggered it throws:

Code: Select all

Error: No component factory found for DynamicDialogComponent. Did you add it to @NgModule.entryComponents?
This is not my own component, ie: I've not forgotten to add them to the module's entryComponents array.

If I add this component (primeng/components/dynamicdialog/dynamicdialog) to the module in Declarations and entryComponents, it will get a little further but then crashes trying to pull values (that don't exist) from the DynamicDialogRef:

Code: Select all

ERROR TypeError: Cannot read property 'viewContainerRef' of undefined
    at DynamicDialogComponent.push.2bbZ.DynamicDialogComponent.loadChildComponent (dynamicdialog.js:41)
    at DynamicDialogComponent.push.2bbZ.DynamicDialogComponent.ngAfterViewInit (dynamicdialog.js:30)
I'm hoping this doesn't mean I will be forced to move to Prime 11 - can someone explain what is happening?

Thanks!

Withnail73
Posts: 5
Joined: 01 Nov 2019, 18:32

24 Feb 2021, 14:40

Ok... so worked out it was related to the Ivy compilation which I disabled in order for the v8 Prime comps to build correctly. But, it seems the entryComponents array is still being ignored as all my dynamic components are not defined. Will continue the google-fest...

Withnail73
Posts: 5
Joined: 01 Nov 2019, 18:32

25 Feb 2021, 18:10

Problem resolved and I'm ashamed to say it was a silly one! Somehow (probably during the initial Prime migration to 11) the DynamicDialogModule had been removed from all modules:

Code: Select all

import { DynamicDialogModule } from 'primeng/dynamicdialog';
Added it back everywhere and the problem's gone. I'll get my coat.... :oops:

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests