Drawer抽屉
- 当需要一个附加的面板来控制父窗体内容,这个面板在需要时呼出。比如,控制界面展示样式,往界面中添加内容。
- 当需要在当前任务流中插入临时任务,创建或预览附加内容。比如展示协议条款,创建子对象。
基础抽屉
基础抽屉,点击触发按钮抽屉从右滑出,点击遮罩区关闭
@Component({
selector: 'nz-demo-drawer-basic-right',
template: `
<button nz-button nzType="primary" (click)="open()">Open</button>
<nz-drawer [nzClosable]="false" [nzVisible]="visible" nzPlacement="right" nzTitle="Basic Drawer" (nzOnClose)="close()">
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</nz-drawer>
`
})
export class NzDemoDrawerBasicRightComponent {
visible = false;
open(): void {
this.visible = true;
}
close(): void {
this.visible = false;
}
}
对象编辑
多层抽屉
在抽屉内打开新的抽屉,用以解决多分支任务的复杂状况。
import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-drawer-multi-level-drawer',
template: `
<button nz-button nzType="primary" (click)="open()">New Cookbook</button>
<nz-drawer
[nzClosable]="false"
[nzOffsetX]="childrenVisible ? 180 : 0"
[nzWidth]="320"
[nzVisible]="visible"
nzTitle="Cookbook"
(nzOnClose)="close()"
>
<form nz-form>
<div nz-row>
<div nz-col nzSpan="24">
<nz-form-item>
<nz-form-label>Name</nz-form-label>
<nz-form-control>
<input nz-input placeholder="please enter cookbook name" />
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row>
<div nz-col nzSpan="24">
<nz-form-item>
<nz-form-label>Food</nz-form-label>
<nz-form-control>
<nz-tag>potato</nz-tag>
<nz-tag>eggplant</nz-tag>
</nz-form-control>
</nz-form-item>
</div>
</div>
</form>
<nz-drawer [nzClosable]="false" [nzVisible]="childrenVisible" nzTitle="Food" (nzOnClose)="closeChildren()">
<nz-list [nzDataSource]="vegetables" [nzRenderItem]="item">
<ng-template #item let-item>
<nz-list-item [nzContent]="item"></nz-list-item>
</ng-template>
</nz-list>
</nz-drawer>
</nz-drawer>
`
})
export class NzDemoDrawerMultiLevelDrawerComponent {
visible = false;
childrenVisible = false;
vegetables = ['asparagus', 'bamboo', 'potato', 'carrot', 'cilantro', 'potato', 'eggplant'];
open(): void {
this.visible = true;
}
close(): void {
this.visible = false;
}
openChildren(): void {
this.childrenVisible = true;
}
closeChildren(): void {
this.childrenVisible = false;
}
}
自定义位置
信息预览抽屉
需要快速预览对象概要时使用,点击遮罩区关闭。
import { Component } from '@angular/core';
@Component({
selector: 'nz-demo-drawer-user-profile',
template: `
<nz-list [nzDataSource]="data" [nzRenderItem]="item" [nzItemLayout]="'horizontal'">
<ng-template #item let-item>
<nz-list-item [nzActions]="[viewAction]">
<ng-template #viewAction>
<a (click)="open()">View Profile</a>
</ng-template>
<nz-list-item-meta
[nzTitle]="nzTitle"
nzDescription="Progresser AFX"
>
<ng-template #nzTitle>
<a href="https://ng.ant.design">{{ item.name }}</a>
</ng-template>
</nz-list-item-meta>
</nz-list-item>
</ng-template>
</nz-list>
<nz-drawer [nzVisible]="visible" [nzWidth]="640" [nzClosable]="false" (nzOnClose)="close()">
<p class="title" style=" margin-bottom: 24px;">User Profile</p>
<nz-descriptions [nzColumn]="2" nzTitle="Personal">
<nz-descriptions-item nzTitle="Full Name" [nzSpan]="1">Lily</nz-descriptions-item>
<nz-descriptions-item nzTitle="Account" [nzSpan]="1">AntDesign@example.com</nz-descriptions-item>
<nz-descriptions-item nzTitle="City" [nzSpan]="1">HangZhou</nz-descriptions-item>
<nz-descriptions-item nzTitle="Country" [nzSpan]="1">China🇨🇳</nz-descriptions-item>
<nz-descriptions-item nzTitle="Website" [nzSpan]="1"> - </nz-descriptions-item>
<nz-descriptions-item nzTitle="Message" [nzSpan]="2">
Make things as simple as possible but no simpler.
</nz-descriptions-item>
</nz-descriptions>
<nz-divider></nz-divider>
<nz-descriptions [nzColumn]="2" nzTitle="Company">
<nz-descriptions-item nzTitle="Position" [nzSpan]="1">Programmer</nz-descriptions-item>
<nz-descriptions-item nzTitle="Responsibilities" [nzSpan]="1">Coding</nz-descriptions-item>
<nz-descriptions-item nzTitle="Department" [nzSpan]="1">AFX</nz-descriptions-item>
<nz-descriptions-item nzTitle="Supervisor" [nzSpan]="1">Lin</nz-descriptions-item>
<nz-descriptions-item nzTitle="Skills" [nzSpan]="2">
C / C + +, data structures, software engineering, operating systems, computer networks, databases, compiler theory, computer
architecture, Microcomputer Principle and Interface Technology, Computer English, Java, ASP, etc.
</nz-descriptions-item>
</nz-descriptions>
<nz-divider></nz-divider>
<nz-descriptions [nzColumn]="2" nzTitle="Contacts">
<nz-descriptions-item nzTitle="Email" [nzSpan]="1">AntDesign@example.com</nz-descriptions-item>
<nz-descriptions-item nzTitle="Phone Number" [nzSpan]="1">+86 181 0000 0000</nz-descriptions-item>
<nz-descriptions-item nzTitle="Github" [nzSpan]="2">
<a href="https://github.com/NG-ZORRO/ng-zorro-antd" target="_blank">github.com/NG-ZORRO/ng-zorro-antd</a>
</nz-descriptions-item>
</nz-descriptions>
</nz-drawer>
`,
styles: [
`
.title {
font-size: 16px;
color: rgba(0, 0, 0, 0.85);
line-height: 24px;
display: block;
margin-bottom: 16px;
}
.item-wrap {
font-size: 14px;
line-height: 22px;
margin-bottom: 7px;
color: rgba(0, 0, 0, 0.65);
}
.label {
margin-right: 8px;
display: inline-block;
color: rgba(0, 0, 0, 0.85);
}
`
]
})
export class NzDemoDrawerUserProfileComponent {
data = [
{
name: 'Lily'
},
{
name: 'Lily'
}
];
visible = false;
open(): void {
this.visible = true;
}
close(): void {
this.visible = false;
}
服务方式创建