angular2消息弹窗组件
使用方式:
1.添加MsgDialog和MsgDialogService的引用
2.在主页面定义一个msgdialog组件(整个应用程序中只需要定义一次)
<msg-dialog (msgDialogLoaded)="msgDialogLoaded($event)">
3.在component中定义弹窗的初始化函数
msgDialogLoaded(event): void { this.msgDialogService.initializeMsgDialog(event); }
4.使用组件
let dialog = this.msgDialogService.showModal({ title: "Warning", okText: "OK", cancelText: "Cancel", message: "Are you sure you want to delete it?", showCancelButton: showCancelButton }); dialog.onOK.subscribe(() => { this.deleteUser(); }); dialog.onCancel.subscribe(() => { console.log('delete canceled.'); });