所以,我有一个组合框,用户可以在其中输入。我想要实现的是在用户键入不在组合框选择/选项中的内容时发出警告。这是我的组合框的代码:
<mat-form-field appearance="outline" class="width-1">
<mat-label>Aircraft Type (ICAO)</mat-label>
<!-- test autocomplete aircraft type -->
<input
type="text"
placeholder="Aircraft Type (ICAO)"
aria-label="Aircraft Type (ICAO)"
matInput
formControlName="aircraftType"
[matAutocomplete]="type"
(input)="onAircraftTypeChange()"
/>
<span matSuffix class="down">
<mat-icon>arrow_drop_down</mat-icon>
</span>
<mat-autocomplete
#type="matAutocomplete"
(optionSelected)="onSelectAircraftType($event.option.value)"
[displayWith]="displayAircraftTypeFn"
>
<mat-option
*ngFor="let type of filteredAircraftTypes | async"
[value]="type"
>
{{ type.label }}
</mat-option>
</mat-autocomplete>
<!-- end test autocomplete -->
</mat-form-field>