html - 带有 PrimeNG 的 Angular 2 嵌套模态对话框不起作用

标签 html angular primeng primeng-dialog

我正在使用 PrimeNG 对话框组件,我有一个模态对话框,点击一个按钮,我想显示另一个模态对话框。

发生的情况是我的第二个模态对话框不是真正的模态对话框,因为我只看到按钮后面的对话框内容。

我确实更改了第二个模态对话框的 p-dialog 的 [appendTo] 属性,但它似乎无法正常工作。

如何在 p 对话框中打开嵌套对话框?

Angular 2 组件中的对话框:

<p-dialog header="Create/Edit Financial Flow"  [visible]="display$ | async" modal="modal" width="500" height="600" responsive="true" [resizable]="false" [closable]="false">
<financial-flowdialog #myfinancialflowdialog (onCloseDialog) ="closeDialog()" [flowdata]="selectedFlows$ | async"></financial-flowdialog>
</p-dialog>

在第一个模式对话框中单击按钮时,应打开第二个对话框。下面是嵌套对话框的定义:

    <p-dialog header="Title" [(visible)]="display" [appendTo]="body" *ngIf="display" modal="modal" width="500" height="600" responsive="true"
        [resizable]="false" [closable]="false">
        <div class="container-fluid">
            <form (ngSubmit)="onSubmit()">

                <div class="pull-right top-buffer ">
                    <button type="button" class="btn btn-primary" (click)="closeDialog()">Cancel</button>
                    <button type="submit" class="btn btn-primary">Select</button>
                </div>
            </form>
        </div>
    </p-dialog>
    <button type="button" #mybtn [value]="value" ngDefaultControl [formControlName]="key" [id]="key" [ngStyle]="style" (click)="openDialog()">{{label}}</button>

我可以打开第一个对话框,但是当我单击按钮打开第二个对话框时,对话框的内容显示为一个普通的 div。在呈现的 html 下方:

<section>
    <div id="nestediag" ng-reflect-form="[object Object]" class="ng-pristine ng-invalid ng-touched">
        <!--template bindings={
  "ng-reflect-ng-if": "true"
}--><p-dialog header="Title" height="600" modal="modal" responsive="true" width="500" ng-reflect-visible="true">
            <div class="container-fluid">
                <form class="ng-untouched ng-pristine ng-valid">

                    <div class="pull-right top-buffer ">
                        <button class="btn btn-primary" type="button">Cancel</button>
                        <button class="btn btn-primary" type="submit">Select</button>
                    </div>
                </form>
            </div>
        </p-dialog>
        <button ngdefaultcontrol="" type="button" value="Select a payee" ng-reflect-name="flowpayee" ng-reflect-ng-style="[object Object]" ng-reflect-value="Select a payee" ng-reflect-id="flowpayee" id="flowpayee" class="ng-pristine ng-valid ng-touched" style="width: 100%;">Select a payee</button>
    </div>
</section>

最佳答案

您可以通过使用 appendTo 属性将第二个对话框附加到文档主体来解决此问题,例如

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

关于html - 带有 PrimeNG 的 Angular 2 嵌套模态对话框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41289430/

相关文章:

php - Angular2 和 xampp 服务器

angular - 如何对可编辑 primeng 数据表实现响应式(Reactive)表单方法

javascript - FormArray 中的嵌套 FormGroup 重复所有单选按钮值 - Angular(带有 PrimeNG 的 UI)

html - 无论父级的纵横比如何,都保持 div 纵横比并居中

node.js - Angular Cli 构建命令启动速度非常慢

javascript - 检查具有事件类的元素并向下滑动它下面的下一个元素

angular - 从 Angular 库加载一个模块而不是加载整个库

html - PrimeNG fieldset css 和网站原来的不一样

html - 如何居中对齐 Google 广告?

javascript - 使用javascript用换行符替换html <br>元素