AngularMaterial无法过滤选项
创始人
2024-10-28 11:01:45
0
  1. 确认使用的版本是否支持过滤功能。在使用mat-select时,需要在module中导入MatSelectModule,并且设置formControl属性,如下所示:
import { MatSelectModule } from '@angular/material/select';
import { ReactiveFormsModule } from '@angular/forms';

@NgModule({
 imports: [
   ReactiveFormsModule,
   MatSelectModule
 ],
 declarations: [AppComponent],
 bootstrap: [AppComponent]
})
export class AppModule { }
  1. 确认是否正确使用matAutocomplete指令。例如,如果要过滤mat-option选项,请确保您已经将matAutocomplete指令添加到input元素上,如下所示:

  
  
    
      {{option}}
    
  

  1. 确认过滤条件是否正确。您可以根据需要过滤选项,例如根据输入的文本过滤选项,如下所示:
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无法过滤选项的方法。

相关内容

热门资讯

今天下午!哈糖大菠萝有没有挂,... 今天下午!哈糖大菠萝有没有挂,德普辅助软件,原来真的是有挂(有挂教学)1、完成德普辅助软件有辅助插件...
规律辅助挂!hhpoker有作... 规律辅助挂!hhpoker有作弊的吗,如何下载德普之星辅助软件,真是是有挂(果真有挂)1、用户打开应...
迎来新发展!约局吧德州真的存在... 迎来新发展!约局吧德州真的存在透视吗,智星菠萝透视,好像确实有挂(有挂讲解)1、很好的工具软件,可以...
据监测!werplan怎么作弊... 据监测!werplan怎么作弊,德普之星透视辅助软件下载,总是是真的有挂(了解有挂)1、德普之星透视...
经调查!aapoker辅助器怎... 经调查!aapoker辅助器怎么用,德普之星有透视辅助吗,果然存在有挂(有挂教程)在进入德普之星有透...
教程辅助挂!wepoker透视... 教程辅助挂!wepoker透视脚本免费下载,智星菠萝辅助,切实真的有挂(有挂分析)1.智星菠萝辅助 ...
2026版复盘!菠萝德普辅助器... 2026版复盘!菠萝德普辅助器免费版在哪里,德普之星app安卓版破解版,果然真的是有挂(确实有挂)1...
近日!红龙poker辅助平台,... 近日!红龙poker辅助平台,德扑之星有透视辅助吗,总是存在有挂(的确有挂)1.德扑之星有透视辅助吗...
值得注意的是!hhpoker到... 值得注意的是!hhpoker到底可以作弊吗,德扑之星透视软件免费入口官网,好像存在有挂(有挂助手)1...
教程辅助挂!pokemmo脚本... 教程辅助挂!pokemmo脚本手机版,德普之星透视辅助软件下载,果然真的有挂(了解有挂)1、德普之星...