相关疑难解决方法(0)

有没有办法在自动完成(Angular4 +)中进行多重选择?

我想通过自动完成对过滤的项目进行多选.灵感来自以下教程 我尝试了这段代码:

组件:

 <form class="example-form">
  <mat-form-field class="example-full-width">
    <input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto">
    <mat-autocomplete #auto="matAutocomplete">
      <mat-option *ngFor="let option of filteredOptions | async" [value]="option" multiple>
      <mat-checkbox>
        {{ option }}
     </mat-checkbox> 
     </mat-option>
    </mat-autocomplete>
  </mat-form-field>
</form>
Run Code Online (Sandbox Code Playgroud)

我添加了标签以启用选择,但它不起作用.一旦我过滤并选择一个选项,菜单就会关闭,复选框甚至都不会被选中.有没有办法在自动完成中进行多重选择?谢谢 !!

typescript angular-material angular

11
推荐指数
3
解决办法
1万
查看次数

标签 统计

angular ×1

angular-material ×1

typescript ×1