基于 NzDrawerService 封装,它解决一些已知问题:
create
this.drawerHelper.create('Edit', FormEditComponent, { i }).subscribe(res => this.load());
// 对于组件的成功&关闭的处理说明
// 成功
this.NzDrawerRef.close(data);
this.NzDrawerRef.close(true);
// 关闭
this.NzDrawerRef.close();
this.NzDrawerRef.close(false);
// 关闭所有已打开的抽屉
this.DrawerHelper.closeAll();
包括 create & static 分别用于打开普通或静态抽屉。
自定义组件HTML模板
内容
<div class="drawer-footer">
// 底部工具条由 `drawer-footer` 包裹
<button nz-button [nzType]="'default'" (click)="cancel()">
Cancel
</button>
<button nz-button [nzType]="'primary'" (click)="ok()">
OK
</button>
</div>
若无需要底部工具条,需要指定参数 footer: false。