带输入的KendoUI对话服务

时间:2017-07-14 04:12:19

标签: angular kendo-ui-angular2

我正在尝试使用KendoUI dialog service使用“确定”和“取消”按钮从用户收集文本输入数据。有关如何执行此操作的任何示例?谢谢!

1 个答案:

答案 0 :(得分:0)

我用这种方式。 例如:

我有服务:

import { Injectable, TemplateRef } from '@angular/core';

import { DialogService, DialogRef, } from '@progress/kendo-angular-dialog';

@Injectable()
export class MyDialogService {

private _currentDialog: DialogRef;

constructor(private dialogService: DialogService) {

}

open(title: string, content: Function) {
    this._currentDialog = this.dialogService.open({
        title: title,
        content: content
    });
};

close() {
    this._currentDialog.close();
}
}

从代码中我的调用如下所示:

this.myDialogService.open('Buying', PopupAuthBuyComponent);

MyComponent的:

@Component({
    templateUrl: './popup-auth-buy.component.html'
})
export class PopupAuthBuyComponent implements OnInit {
... your logic that handles form and works with model
}

MyTemplate的:

<div>
    <form (ngSubmit)="onSubmit()" #buyForm="ngForm">
        <YOUR INPUTS HERE />
        <kendo-dialog-actions>
            <button  kendoButton [primary]="true" type="submit" [disabled]="!buyForm.form.valid">Submit</button>
        </kendo-dialog-actions>
    </form>
</div>

希望,这有帮助。