p-dialog how to reload content on dialog load

UI Components for Angular
Post Reply
jtsdev
Posts: 15
Joined: 21 Dec 2015, 20:11

20 Aug 2018, 21:30

Hi,
I am using p-dialog to show some content on the screen upon request.
To Achieve this I have written a component which handles UI and the backend call to get the data.
I am using component as in below code snippet to show the content on the fly.

<p-dialog [(visible)]="displayDiag" [width]="1200" [height]="400" [modal]="true" [blockScroll]="true" header="Header" >
<app-viewLatestStatus [objectType]="objectType" [objectId]="objectId">
</app-viewLatestStatus>
</p-dialog>

I've written code to call backend in ngOnInit() of app-viewLatestStatus component.
My query is how do I call backend and refresh the data in dialog every time the dialog is shown/displyed.

JACrazy
Posts: 20
Joined: 19 Mar 2018, 17:48

24 Aug 2018, 18:33

Add an ngIf statement and the component will load fresh and call ngOnInit every time you open the dialog. Link the ngIf to the exact same value as the visible toggle (displayDiag).

Code: Select all

<p-dialog [(visible)]="displayDiag" [width]="1200" [height]="400" [modal]="true" [blockScroll]="true" header="Header" *ngIf="displayDiag">
<app-viewLatestStatus [objectType]="objectType" [objectId]="objectId">
</app-viewLatestStatus>
</p-dialog>

johnhoang
Posts: 13
Joined: 12 Apr 2017, 22:39

02 Mar 2020, 15:59

@JACrazy: Thanks a lot. It works for me as well.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests