Angular 2 Nested Modal Dialog with PrimeNG doesn't work

自古美人都是妖i 提交于 2019-11-29 14:52:32

You can solve this problem by appending the second dialog to the document body by using the appendTo attribute, e.g.

<p-dialog appendTo="body">
...
</p-dialog>

Defining a componentref variable and using [appendTo]="Componentref" solve the issue. See discussion https://github.com/primefaces/primeng/issues/656

This worked for me

<p-dialog #parentDialog id='parentDialog' name='parentDialog' header='Parent Dialog #1' modal='modal' [(visible)]='display1'>
  <p>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</p>
  <p-dialog #childDialog header='Child Dialog #2' modal='modal' [(visible)]='display2' appendTo='body'>
    1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 
    <p-footer>
      <button pButton type='button' (click)='display2=false' class='ui-button-primary' label='Close'></button>
    </p-footer>
  </p-dialog>
  <button type='text' (click)='showDialog2()' pButton icon='fa-external-link-square' label='Show'></button>
</p-dialog>
<button type='text' (click)='showDialog1()' pButton icon='fa-external-link-square' label='Show'></button>

and the typescript:

  display1: boolean = false;
  showDialog1() {
    this.display1 = true;
  }
  display2: boolean = false;
  showDialog2() {
    this.display2 = true;
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!