简体   繁体   English

如何重新加载 PrimeNG 对话框的内容

[英]How to reload the contents of a PrimeNG Dialog

I am using Angular PrimeNG and I have the following scenario我正在使用 Angular PrimeNG,我有以下场景

<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?这里的问题是每当我尝试打开 p 对话框时,不会再次调用自定义组件,如何确保再次加载该组件以确保每次打开模态时都有最新数据?

One way is to add an *ngIf statement to the component.一种方法是向组件添加*ngIf语句。 So whenever the flag is false the component is destroyed.因此,只要标志为假,组件就会被销毁。 Opening the dialog again should create the component again.再次打开对话框应该再次创建组件。

Can you please share the changes that you did to make it work. 您能否分享使它生效的更改。 Thank You 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM