-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read properties of undefined (reading 'instance') at DialogService.getInstance #14856
Comments
Encountering the same problem as well. |
same problem and i solved with: this.instance = this.dialogService.dialogComponentRefMap.get(ref)?.instance; |
@salvatoremadonia Didn't solve it for me. |
If what you want is the config object passed on the dialogService.open method, you can workaround by passing a DynamicDialogConfig in the constructor of the component you're opening. Something like this: @Component({
standalone: true,
imports: [DynamicDialogModule],
selector: 'app-dialog-test',
providers: [DialogService],
template: `<p>{{ config.data.message }}</p>`
})
export class DialogTestComponent {
constructor(private ref: DynamicDialogRef, public config: DynamicDialogConfig ) { }
} |
I got the same error, but my dialog shows it's content. My error is in the following method: https://github.com/primefaces/primeng/blob/master/src/app/components/dynamicdialog/dynamicdialog.ts#L329
this.componentRef is undefined. |
In case this helps someone, I completely forgot to import my custom dialog component (standalone) in the component that was opening the dialog. Angular rendered the template but it was not functional and there was no error in the console 😅 |
This problem still remains. viewContainerRef is optional and hence, also this.componentRef. Whereas in the last line, they assume with ".componentRef!.instance" that componentRef exists for sure. |
Bug still is still there. |
Is there any fix or workaround for this bug so far? |
Describe the bug
getInstance method product
Cannot read properties of undefined (reading 'instance') at DialogService.getInstance
error. So component not displaying .Same can be reproduce in PrimeNG dynamic dialog example
Environment
Development
Reproducer
https://stackblitz.com/edit/nga6lg
Angular version
17.1.X
PrimeNG version
17.7.X
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18.9.0
Browser(s)
Edge
Steps to reproduce the behavior
Expected behavior
It should not throw any error and show dynamic dialog component
The text was updated successfully, but these errors were encountered: