如何打开/关闭kendo对话框?

我正在尝试用于角度2的kendo ui和关闭,单击事件似乎在kendo对话框上工作 . 但是有没有方法可以打开和关闭对话框,还是我必须使用javascript?

回答(1)

2 years ago

这里有一个简单的例子:http://plnkr.co/edit/Sm1T3rXkHNb04waFkkzG?p=preview

只需使用简单的 ngIf 指令来控制窗口的打开/关闭状态 .

import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    template: `
    <button (click)="dialogOpen = true">Open Dialog</button>
        <p>Status: {{ status }}</p>

        <kendo-dialog title="Action required" (close)="onDecline()" *ngIf="dialogOpen">
            <p>Do you accept?</p>

            <kendo-dialog-actions>
                <button kendoButton (click)="onAccept()">Yes</button>
                <button kendoButton (click)="onDecline()">No</button>
            </kendo-dialog-actions>
        </kendo-dialog>
    `
})
export class AppComponent {
    public status = "not open";
    dialogOpen : boolean = false;

    public onAccept() { this.status = "accepted"; this.closeDialog(); }
    public onDecline() { this.status = "declined"; this.closeDialog(); }

    private closeDialog() {
      this.dialogOpen = false;
    }
}