forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom.ts
47 lines (43 loc) 路 1.36 KB
/
custom.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Component, TemplateRef, ViewChild } from '@angular/core';
import { NzSegmentedOption } from 'ng-zorro-antd/segmented';
@Component({
selector: 'nz-demo-segmented-custom',
template: `<nz-segmented [nzLabelTemplate]="templateRef" [nzOptions]="options"></nz-segmented>
<ng-template #temp let-index="index">
<ng-container [ngSwitch]="index">
<ng-container *ngSwitchCase="0">
<nz-avatar nzSrc="https://joeschmoe.io/api/v1/random"></nz-avatar>
<div>User 1</div>
</ng-container>
<ng-container *ngSwitchCase="1">
<nz-avatar nzText="K"></nz-avatar>
<div>User 2</div>
</ng-container>
<ng-container *ngSwitchCase="2">
<nz-avatar nzIcon="user"></nz-avatar>
<div>User 3</div>
</ng-container>
</ng-container>
</ng-template> `,
styles: [
`
.code-box-demo {
overflow-x: auto;
}
.ant-segmented {
margin-bottom: 10px;
}
`
]
})
export class NzDemoSegmentedCustomComponent {
@ViewChild('temp', { static: true, read: TemplateRef }) templateRef!: TemplateRef<{
$implicit: NzSegmentedOption;
index: number;
}>;
options = [
{ label: 'user1', value: 'user1', useTemplate: true },
{ label: 'user2', value: 'user2', useTemplate: true },
{ label: 'user3', value: 'user3', useTemplate: true }
];
}