我尝试了什么我尝试了以下方法,但尚未实现所需的行为:
<mat-form-field *ngIf="filter.type === 'organisation'">
<mat-label>LABEL</mat-label>
<input
matInput
placeholder="PLACEHOLDER"
[matAutocomplete]="auto"
(input)="getContractors($event.target.value)"
/>
<mat-autocomplete #auto="matAutocomplete">
<ng-container *ngFor="let serviceType of [1, 2, 3]">
<mat-optgroup
*ngIf="groupedContractors[serviceType]"
[label]="getServiceTypeName(serviceType)"
>
<mat-option
*ngFor="let contractor of groupedContractors[serviceType]"
(click)="onContractorSelect(contractor)"
>
<mat-checkbox [checked]="isSelectedContractor(contractor)">
{{ contractor.name }}
</mat-checkbox>
</mat-option>
</mat-optgroup>
</ng-container>
<mat-option *ngIf="contractors.length < 1" disabled>
TEXT
</mat-option>
</mat-autocomplete>
</mat-form-field>
MatAutocompleteTrigger
我不确定如何在不破坏我当前的实施的情况下进行。有人可以提出一种干净有效的方法来保持下拉菜单开放,同时允许多次选择?
$event.stopPropagation()
,请查看此详细的GitHub讨论和解决方案: