import { MatSelectModule } from '@angular/material/select';
import { ReactiveFormsModule } from '@angular/forms';
@NgModule({
imports: [
ReactiveFormsModule,
MatSelectModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
{{option}}
ngOnInit() {
this.filteredOptions = this.myControl.valueChanges
.pipe(
startWith(''),
map(value => this.filter(value))
);
}
filter(value: string): string[] {
const filterValue = value.toLowerCase();
return this.options.filter(option => option.toLowerCase().includes(filterValue));
}
以上是解决Angular Material无法过滤选项的方法。