ngx-mat-select-search搜索时placeholderLabel、noEntriesFoundLabel不显示问题
问题根因
placeholderLabel和noEntriesFoundLabel是ngx-mat-select-search组件的专属输入属性,你误将两个属性写在了父组件mat-select的标签上,配置无法被搜索组件读取,因此不生效。同时你写的noEntriesFoundLabel属性值多包裹了一层多余的单引号,也可以同步移除。
修正后的代码
<mat-form-field class="search-field-dropdown" appearance="none"> <mat-select formControlName="country" class="matdropdownCustom" placeholder="Country" > <mat-option> <ngx-mat-select-search [formControl]="countryFilterCtrl" placeholderLabel="Find country..." noEntriesFoundLabel="no matching country found" ></ngx-mat-select-search> </mat-option> <mat-option *ngFor="let option1 of filteredCountriesList | async" [value]="option1.name" > {{ option1.name }} </mat-option> </mat-select> </mat-form-field>
如果需要动态修改这两个文案,也可以用方括号绑定组件内的变量,示例:
<ngx-mat-select-search [formControl]="countryFilterCtrl" [placeholderLabel]="'Find country...'" [noEntriesFoundLabel]="'no matching country found'" ></ngx-mat-select-search>
内容的提问来源于stack exchange,提问作者chandoo
相关产品推荐
相关产品推荐

