You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 03:18:02