有没有办法禁用自动完成的输入? - Angular Material

Is there a way to disable typing for autocomplete? - Angular Material

我在 Angular material 中有以下 autocomplete

 <!-- Drop Down menu -->
          <mat-form-field>
            <input placeholder="Select one" [matAutocomplete]="auto" matInput>

            <mat-autocomplete #auto="matAutocomplete">
              <mat-option value="Cars">Cars</mat-option>
              <mat-option value="Books">Books</mat-option>
            </mat-autocomplete>
          </mat-form-field>

有没有办法禁止在 input 上打字,这样用户就不会破坏下拉菜单的用途?现在,用户只需键入内容而不是选择选项,甚至可以在选择时编辑选项。

如果您不希望用户在输入中输入任何内容,而只是从列表中输入 select,为什么不使用 mat-select?用户也可以用键盘select,输入自己需要的内容。文档:https://material.angular.io/components/select/overview

  1. 如果您希望输入字段始终禁用,请使用正常的 select 下拉菜单

  2. 如果你想使用自动完成但不希望用户在输入字段中编辑 selected 选项那么你可能想使用筹码自动完成 - https://material.angular.io/components/chips/examples

这是文档,其中包含禁用自动完成输入的示例

https://material.angular.io/components/autocomplete/examples

我需要在 selection 之后禁用输入并且我不能使用 mat-select 因为我有超过 600 个选项...所以需要自动完成/提前输入。也不能使用 mat-chips,因为一次只能选择一个 selection。

stackblitz = https://stackblitz.com/angular/kopovlnpxapb?file=src%2Fapp%2Fautocomplete-overview-example.ts