No component factory found for DynamicDialogComponent

UI Components for Angular
Post Reply
athletechs
Posts: 8
Joined: 15 Oct 2016, 21:38

08 Jan 2019, 21:31

I have a feature module (which is not app module), where I am trying to define a dynamic dialog. I am using Angular 7.2.0 and PrimeNG 7.0.4.

I created a Component called BadgeComponent.

I have updated my module to import BadgeComponent. I added BadgeComponent to the declarations, entryComponents and exports.

The calling component has imported { DialogService } from 'primeng/api'; along with the BadgeComponent.

The dialog is triggered with this code:
const ref = this.dialogService.open(BadgeComponent, {
header: 'Print Badge',
width: '35%',
contentStyle: {"max-height": "350px", "overflow": "auto"}
});

Everything compiles and when I trigger the dialog to appear I get a message:

ERROR Error: No component factory found for DynamicDialogComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (VM1500 vendor.js:19396)
at CodegenComponentFactoryResolver.push../node_modules/@angular/core/fesm5/core.js.CodegenComponentFactoryResolver.resolveComponentFactory (VM1500 vendor.js:19434)
at DialogService.push../node_modules/primeng/components/dynamicdialog/dialogservice.js.DialogService.appendDialogComponentToBody (VM1500 vendor.js:85551)
at DialogService.push../node_modules/primeng/components/dynamicdialog/dialogservice.js.DialogService.open (VM1500 vendor.js:85537)


I tried a lot of different combinations but can't get this to work. Could someone shed some light on what I might be doing incorrectly?

Thanks!
Dave

yigitfindikli
Posts: 449
Joined: 08 Aug 2018, 14:09

09 Jan 2019, 11:32

Hi,
Did you add DialogService provider in your main component ?

Code: Select all

@Component({
    templateUrl: './dynamicdialogdemo.html',
    providers: [DialogService, MessageService]
})
export class DynamicDialogDemo {

    constructor(public dialogService: DialogService, public messageService: MessageService) {}

    show() {
        const ref = this.dialogService.open(CarsListDemo, {
            header: 'Choose a Car',
            width: '70%',
            contentStyle: {"max-height": "350px", "overflow": "auto"}
        });

        ref.onClose.subscribe((car: Car) =>{
            if (car) {
                this.messageService.add({severity:'info', summary: 'Car Selected', detail:'Vin:' + car.vin});
            }
        });
    }

}

athletechs
Posts: 8
Joined: 15 Oct 2016, 21:38

09 Jan 2019, 16:03

Yes

yigitfindikli
Posts: 449
Joined: 08 Aug 2018, 14:09

11 Jan 2019, 08:48

athletechs wrote:
09 Jan 2019, 16:03
Yes
Hi can i see your code ?

Akahadaka
Posts: 1
Joined: 23 Jul 2019, 22:34

23 Jul 2019, 22:39

Did you ever figure this one out? Sitting with a similar issue. Have added as

Code: Select all

declarations and entryComponents

imaa2aroi
Posts: 5
Joined: 30 Apr 2019, 15:41

24 Jul 2019, 16:07

i face this when i create this sample ,

see inside its resolved

https://stackblitz.com/edit/angular-1ri ... onent.html

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests