` | - |
| `[nzServerSearch]` | 是否使用服务端搜索,当为 true 时,将不再在前端对 nz-option 进行过滤 | `boolean` | `false` |
| `[nzFilterOption]` | 是否根据输入项进行筛选。当其为一个函数时,会接收 `inputValue` `option` 两个参数,当 `option` 符合筛选条件时,应返回 `true`,反之则返回 `false`。 | `(input?: string, option?: NzOptionComponent) => boolean;` | - |
| `[nzMaxMultipleCount]` | 最多选中多少个标签| `number` | `Infinity` |
diff --git a/components/select/nz-select-top-control.component.html b/components/select/nz-select-top-control.component.html
index 29df8ab3f87..e4ef5d7ceb4 100644
--- a/components/select/nz-select-top-control.component.html
+++ b/components/select/nz-select-top-control.component.html
@@ -21,7 +21,12 @@
class="ant-select-selection-selected-value"
[attr.title]="nzSelectService.listOfCachedSelectedOption[0]?.nzLabel"
[ngStyle]="selectedValueStyle">
- {{ nzSelectService.listOfCachedSelectedOption[0]?.nzLabel }}
+
+
+
+
+ {{ nzSelectService.listOfCachedSelectedOption[0]?.nzLabel }}
+
;
@Input() nzSuffixIcon: TemplateRef;
@Input() nzClearIcon: TemplateRef;
@Input() nzRemoveIcon: TemplateRef;
diff --git a/components/select/nz-select.component.html b/components/select/nz-select.component.html
index d0faae40c0b..f5bd566679c 100644
--- a/components/select/nz-select.component.html
+++ b/components/select/nz-select.component.html
@@ -10,13 +10,12 @@
[nzMaxTagCount]="nzMaxTagCount"
[nzShowArrow]="nzShowArrow"
[nzLoading]="nzLoading"
+ [nzCustomTemplate]="nzCustomTemplate"
[nzSuffixIcon]="nzSuffixIcon"
[nzClearIcon]="nzClearIcon"
[nzRemoveIcon]="nzRemoveIcon"
[nzShowSearch]="nzShowSearch"
[nzTokenSeparators]="nzTokenSeparators"
- [class.ant-select-selection--single]="nzSelectService.isSingleMode"
- [class.ant-select-selection--multiple]="nzSelectService.isMultipleOrTags"
(keydown)="onKeyDown($event)">
{
expect(targetElement.style.width).toBe('');
expect(targetElement.style.minWidth).toBe('10px');
}));
+ it('should custom template work', () => {
+ select.nativeElement.click();
+ fixture.detectChanges();
+ expect(testComponent.open).toBe(true);
+ fixture.detectChanges();
+ overlayContainerElement.querySelector('li').click();
+ fixture.detectChanges();
+ const selection = select.nativeElement.querySelector('.ant-select-selection') as HTMLElement;
+ expect(selection.textContent).toContain('Label: Jack Value: jack');
+ });
it('should click option close dropdown', () => {
testComponent.showSearch = true;
select.nativeElement.click();
@@ -406,6 +416,7 @@ describe('nz-select component', () => {
[nzDropdownMatchSelectWidth]="dropdownMatchSelectWidth"
[nzDropdownStyle]="dropdownStyle"
[nzDropdownClassName]="'test-class'"
+ [nzCustomTemplate]="custom"
(nzOnSearch)="onSearch($event)"
[nzPlaceHolder]="placeholder"
>
@@ -413,6 +424,14 @@ describe('nz-select component', () => {
+
+
+ Label: {{selected.nzLabel}}
+
+
+ Value: {{ selected.nzValue }}
+
+
`
})
export class NzTestSelectDefaultComponent {
diff --git a/components/select/nz-select.component.ts b/components/select/nz-select.component.ts
index fa134c83924..3660b0a51d8 100644
--- a/components/select/nz-select.component.ts
+++ b/components/select/nz-select.component.ts
@@ -108,6 +108,7 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
@Input() nzPlaceHolder: string;
@Input() nzMaxTagCount: number;
@Input() nzDropdownRender: TemplateRef;
+ @Input() nzCustomTemplate: TemplateRef;
@Input() nzSuffixIcon: TemplateRef;
@Input() nzClearIcon: TemplateRef;
@Input() nzRemoveIcon: TemplateRef;