简体   繁体   中英

p-dialog onHide is not working with ngIf?

Already SO has the similar question , I tried with those solution but not working.

Actual the problem is onHide event is not triggering because of the *ngIf , If I removed the *ngIf onHide is triggering.

 <p-dialog [(header)]="dialogText" *ngIf="displayDlg" [(visible)]="displayDlg" 
  [modal]="true" [responsive]="true" (onHide)="close()">

But the problem is I am having the form inside the <p-dialog If I am not using the *ngIf I am getting the undefined error when loading the page. How can I fix this issue.?

    <ng-container *ngIf="displayDlg">
        <p-dialog [(header)]="dialogText" [(visible)]="displayDlg" 
        [modal]="true" [responsive]="true" (onHide)="close()">
    </ng-container>

add your form loading logic in *ngIf of ng-container.

I had the same problem. Solved by using a different boolean variable for the *ngIf in the p-dialog tag compared to the [(visible)] attribute. Using the same variable for both it did not work for me. That is the basic idea. I did it in an object oriented way. I won't bore you with further details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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