html - 无法在 ngx-mat-select-search 上输入搜索

标签 html angular angular-material

我在使用 ngx-mat-select-search 时遇到搜索问题。我可以显示选项,但无法输入其他选项进行搜索。我输入了内容,但屏幕上没有显示我输入的任何内容。

有人可以帮助我吗?

这是我的代码:

<div *ngIf="testForStack()" class="test-form-group mt-5">
  <div class="row">
    <div class="col-md-2">
      <label for="test-form-clientId" class="test-form-lbl test-form-lbl--required">
                            {{'CLIENTE.RESPONSIBLE' | translate}}
                        </label>
    </div>
    <div class="col-md-4 mt-1">
      <mat-form-field class="test-form-field">
        <mat-select id="test-form-origin" formControlName="client" required>
          <mat-option>
            <ngx-mat-select-search ngDefaultControl [formControl]="client" noEntriesFoundLabel="No results found" placeholderLabel="Search" attr.aria-label="{{'GERAL.RESPONSAVEL' | translate}}" (change)="filterByTest($event)">
              <mat-icon ngxMatSelectSearchClear>delete</mat-icon>
            </ngx-mat-select-search>
          </mat-option>
          <mat-option *ngFor="let item of filteredClientsData" [value]="item">{{item.code}} - {{item.name}}</mat-option>
        </mat-select>
      </mat-form-field>
    </div>
    <div class="col-md-2">
      <label for="test-form-clientName" class="test-form-lbl">
                            {{'CLIENTE.NOME_DO_CLIENTE' | translate}}
                        </label>
    </div>
    <div class="col-md-4 mt-1">
      <label id="test-form-clientName">{{clientName}}</label>
    </div>
  </div>
</div>

Where search should be

最佳答案

我在我的 Angular 应用程序中遇到了这个问题,但我使用下面提到的以下步骤解决了这个问题-

  1. 使用此命令在您的应用程序中安装 mat-select-search - npm install ngx-mat-select-search

  2. 导入app.module.ts文件中的NgxMatSelectSearchModule和MatSelectModule。

    从'@angular/material/select'导入{MatSelect};

    从“ngx-mat-select-search”导入 { NgxMatSelectSearchModule };

  3. 如果您在子组件中使用ngx-mat-select-search,请确保在子组件中导入NgxMatSelectSearchModuleMatSelectModule .module.ts 文件也是如此。

    或者您可以创建material.ts文件并导入所有组件然后定义它 app.module.ts 文件和 child.module.ts 文件。

    引用-https://stackblitz.com/edit/mat-select-search-gbvzkn?file=app%2Fmat-select-search%2Fmat-select-search.component.scss,app%2Fmat-select-search%2Fmat-select-search.component.html,app%2Fapp.component.html

关于html - 无法在 ngx-mat-select-search 上输入搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69465559/

相关文章:

html - 带有粘性标题和水平、垂直滚动条的垫表

html - 无法将 <button> 放置在 <li> 中

javascript - 在外面点击如何恢复正常? [Javascript]

html - 在 CSS 中使用 <section>

angular - 如何将多个 Action 与可观察的结合起来?

angular - 如何修复我的 Angular 测验应用程序中多选题的评分问题?

jquery - 如何使用 jQuery 中的切换按钮返回到原始状态?

angular - 如何以 Angular 创建测试用例以检查本地存储中是否存在值

angular - 如何将模板发送到 Angular 中的对话框组件

javascript - 垫自动完成功能未正确过滤 Angular