1

当您查看官方示例时,自动完成列表会在使用 Tab 失去焦点时关闭: Angular Material Autocomplete documentation/example

在我的实现中,当“跳出”控件时,弹出窗口保持打开状态。只有当我在其他地方用鼠标单击或选择建议的元素时,它才会关闭。我做错了什么,它的行为不像原始元素?我有最新的 Material 版本,如果我使用 FormControls 而不是 [(ngModel)] 也是一样的...

    <mat-form-field>
      <input matInput 
          type="text"
          placeholder="Market Name" 
          [(ngModel)]="marketname" 
          [matAutocomplete]="auto">
      <mat-autocomplete #auto="matAutocomplete" class="autocomplete">
        <mat-option *ngFor="let m of marketnames" [value]="m" class="option">{{m}}</mat-option>
      </mat-autocomplete>
    </mat-form-field>
4

0 回答 0