如何在Angular4中的PRIMENG中的Dialog组件的标题中创建一个按钮

时间:2017-10-24 19:40:08

标签: angular primeng

我想在primeng中的对话框窗口的标题中添加一个按钮。代码的链接是https://www.primefaces.org/primeng/#/dialog

要求是在顶部标题的右侧添加两个按钮(图像或任何图标作为计算器和quesstion标记),这些按钮应调用方法abc()。

代码如下: -

model.component.html
---------------------
<p-dialog header="top header title pass here" [(visible)]="display" modal="modal" 
draggable="true" dismissableMask="true" positionTop="50" padding="0px" width="1200" 
height="350" [responsive]="true">
   // here two buttons btn1 and btn2(with icons) next to 'fa fa-fw fa-close' icon.
    <p>The stor.</p>
    <p-footer>
        <button type="button" pButton icon="fa-check" (click)="display=false" 
         label="Yes">hghk</button>
    </p-footer>
</p-dialog>

 <button type="button" (click)="showDialog()" pButton icon="fa-external-link-square" 
  label="Show">Lead</button>

model.component.ts
---------------------
  display = false;
  showDialog() {
    this.display = true;
  }

2 个答案:

答案 0 :(得分:4)

您需要使用p对话框的p-header属性,如下所示:

Button BreakFast = FindViewById<Button>(Resource.Id.BTN_MAINMENU_BREAKFAST);
 BreakFast.Click += delegate {SetContentView(Resource.Layout.BreakfastMenu);};

然后,您应该能够添加将按钮浮动到标题右侧的css。

答案 1 :(得分:1)

使用<p-header>标记:

<p-dialog [(visible)]="display">
    <p-header>
        Header content here <button type="button" (click)="headerBtn()" pButton icon="fa fa-address-book" label="header"></button>
    </p-header>

    Modal Content

    <p-footer>
        <button type="button" pButton icon="fa-check" label="Yes"></button>
    </p-footer>
</p-dialog>

<button type="button" pButton label="modal" (click)="displayDialog()"></button>

我制作了一个plunker,展示了如何在模态标题中添加一个按钮: