Search code examples
angularprimengprimeng-dialog

How to reload the contents of a PrimeNG Dialog


I am using Angular PrimeNG and I have the following scenario

<button (click)="display = !display">Open</button>
<p-dialog [(visible)]="display">
    <custom-component [uid]="userId"></custom-component>
</p-dialog> 

Problem here is whenever I try to open the p-dialog, the custom component is not called again, how do I make sure the component is loaded again to make sure the modal has latest data every time its opened?


Solution

  • One way is to add an *ngIf statement to the component. So whenever the flag is false the component is destroyed. Opening the dialog again should create the component again.