本文整理汇总了TypeScript中ng-zorro-antd.NzModalService类的典型用法代码示例。如果您正苦于以下问题:TypeScript NzModalService类的具体用法?TypeScript NzModalService怎么用?TypeScript NzModalService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NzModalService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(modalSrv: NzModalService) {
modalSrv.closeAll();
}
示例2: constructor
constructor(private router: Router, modalSrv: NzModalService) {
modalSrv.closeAll();
}
示例3: showConfirm
showConfirm(): void {
this.modalService.confirm({
nzTitle : '<i>Do you Want to delete these items?</i>',
nzContent: '<b>Some descriptions</b>',
nzOnOk : () => console.log('OK')
});
}
示例4: info
info(): void {
this.modalService.info({
nzTitle: 'This is a notification message',
nzContent: '<p>some messages...some messages...</p><p>some messages...some messages...</p>',
nzOnOk: () => console.log('Info OK')
});
}
示例5: open
/**
* 打开对话框,默认会过滤一些事件的回调,因此更容易处理回调:
* this.modalHelper.open(FormEditComponent, { i }).subscribe(res => this.load());
*
* 对于组件的成功&关闭的处理说明:
* 成功:
* this.subject.destroy('onOk');
* 若需要回调用参数则:
* this.subject.next(data);
* this.subject.destroy();
*
* 关闭:
* this.subject.destroy();
*
* @param {*} comp 组件
* @param {*} [params] 组件参数
* @param {('sm' | 'lg' | '' | number)} [size='lg'] 大小;例如:lg、600,默认:lg
* @param {*} [options] 对话框ConfigInterface参数
*/
open(comp: any, params?: any, size: 'sm' | 'lg' | '' | number = 'lg', options?: any): Observable<any> {
let cls = '', width = '';
if (size) {
if (typeof size === 'number') {
width = `${size}px`;
} else {
cls = `modal-${size}`;
}
}
return this.modalSrv
.open(Object.assign({
wrapClassName: cls,
content: comp,
width: width ? width : undefined,
footer: false,
componentParams: params
}, options || {}))
.pipe(filter((res: any) => {
let findIdx = -1;
if (typeof res === 'string') {
const resStr = res as string;
findIdx = ['onShow', 'onShown', 'onHide', 'onHidden', 'onCancel', 'onDestroy'].findIndex(w => resStr.startsWith(w));
}
return findIdx === -1;
}));
}
示例6: success
success(): void {
const modal = this.modalService.success({
nzTitle: 'This is a notification message',
nzContent: 'This modal will be destroyed after 1 second'
});
window.setTimeout(() => modal.destroy(), 1000);
}
示例7: showConfirm
showConfirm(): void {
this.confirmModal = this.modal.confirm({
nzTitle: 'Do you Want to delete these items?',
nzContent: 'When clicked the OK button, this dialog will be closed after 1 second',
nzOnOk: () => new Promise((resolve, reject) => {
setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
}).catch(() => console.log('Oops errors!'))
});
}
示例8: catchError
catchError((err: HttpResponse<any>, caught: Observable<any>) => { // 返回异常
if (err.status === 401) {
this.confirmSrv.warning({
nzTitle: '提示',
nzContent: '登录超时,请重新登录!',
nzOnOk: () => { }
});
}
return Observable.create(observer => observer.next(event));
})
示例9:
@HostListener('click')
_click() {
this.confirmServ.confirm({
title: 'Make sure clear all local storage?',
onOk: () => {
localStorage.clear();
this.messageServ.success('Clear Finished!');
}
});
}
示例10: showDeleteConfirm
showDeleteConfirm(): void {
this.modalService.confirm({
nzTitle : 'Are you sure delete this task?',
nzContent : '<b style="color: red;">Some descriptions</b>',
nzOkText : 'Yes',
nzOkType : 'danger',
nzOnOk : () => console.log('OK'),
nzCancelText: 'No',
nzOnCancel : () => console.log('Cancel')
});
}
示例11: view
public view(profile: Contact) {
const modal = this.modalService.create({
nzTitle: null,
nzFooter: null,
nzClassName: 'card-modal',
nzMaskStyle: {backgroundColor: 'transparent'},
nzContent: ProfileComponent,
nzComponentParams: {
profile: profile
}
});
}
示例12: Observable
return new Observable((observer) => {
this.confirmSrv.confirm({
title: '确认要离开吗?',
content: '你已经填写了部分表单离开会放弃已经填写的内容。',
okText: '离开',
cancelText: '取消',
onOk: () => {
observer.next(true);
observer.complete();
},
onCancel: () => {
observer.next(false);
observer.complete();
}
});
});
示例13: successHandle
this.tenantApi.listCurrent().subscribe(tenants => {
console.log(tenants.data);
if (tenants.data.length <= 0) {
this.message.error('未绑定租户');
return;
}
if (tenants.data.length <= 1) {
successHandle(tenants.data[0]);
} else {
const modal = this.modal.create({
nzTitle: '选择公司',
nzWidth: '521px',
nzContent: LoginTenantSelectComponent,
nzComponentParams: {
tenants: tenants.data
},
nzFooter: null
});
modal.afterClose.subscribe((t: Tenant) => {
successHandle(t);
});
}
});
示例14: warning
warning(): void {
this.modalService.warning({
nzTitle: 'This is an warning message',
nzContent: 'some messages...some messages...'
});
}
示例15: error
error(): void {
this.modalService.error({
nzTitle: 'This is an error message',
nzContent: 'some messages...some messages...'
});
}