forked from NG-ZORRO/ng-zorro-antd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
avatar.ts
executable file
路40 lines (37 loc) 路 1.46 KB
/
avatar.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
import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'nz-demo-mention-avatar',
encapsulation: ViewEncapsulation.None,
template: `
<nz-mention [nzSuggestions]="webFrameworks" [nzValueWith]="valueWith" (nzOnSelect)="onSelect($event)">
<textarea rows="1" nz-input nzMentionTrigger [(ngModel)]="inputValue"></textarea>
<ng-container *nzMentionSuggestion="let framework">
<nz-avatar nzSize="small" [nzText]="framework.name" [nzSrc]="framework.icon"></nz-avatar>
<span>{{ framework.name }} - {{ framework.type }}</span>
</ng-container>
</nz-mention>
`,
styles: [
`
.ant-avatar.ant-avatar-sm {
width: 14px;
height: 14px;
margin-right: 8px;
position: relative;
}
`
]
})
export class NzDemoMentionAvatarComponent {
inputValue?: string;
webFrameworks = [
{ name: 'React', type: 'JavaScript', icon: 'https://zos.alipayobjects.com/rmsportal/LFIeMPzdLcLnEUe.svg' },
{ name: 'Angular', type: 'JavaScript', icon: 'https://zos.alipayobjects.com/rmsportal/PJTbxSvzYWjDZnJ.png' },
{ name: 'Dva', type: 'Javascript', icon: 'https://zos.alipayobjects.com/rmsportal/EYPwSeEJKxDtVxI.png' },
{ name: 'Flask', type: 'Python', icon: 'https://zos.alipayobjects.com/rmsportal/xaypBUijfnpAlXE.png' }
];
valueWith = (data: { name: string; type: string; icon: string }): string => data.name;
onSelect(value: string): void {
console.log(value);
}
}