Angularmat-autocomplete未显示下拉选项
创始人
2024-10-28 06:31:04
0
  1. 确保输入框绑定了matAutocomplete指令,并检查matAutocomplete选项的命名是否正确。

  2. 确保提供了正确的数据源。

  3. 检查mat-form-field是否正确包含了mat-autocomplete。

  4. 确保app.module.ts中包含了MatAutocompleteModule。

  5. 检查提供的数据源是否为空或格式不正确。

以下是一个示例代码:

HTML:


  
  
    
      {{ country }}
    
  

TS:

import { Component } from '@angular/core';
import { FormControl } from '@angular/forms';
import { Observable } from 'rxjs';
import { startWith, map } from 'rxjs/operators';

@Component({
  selector: 'autocomplete-example',
  templateUrl: 'autocomplete-example.html',
  styleUrls: ['autocomplete-example.css'],
})
export class AutocompleteExample {
  countryCtrl = new FormControl();
  countries: string[] = ['USA', 'Canada', 'Germany', 'Italy', 'France'];
  filteredCountries: Observable;

  constructor() {
    this.filteredCountries = this.countryCtrl.valueChanges.pipe(
      startWith(''),
      map((value) => this.filter(value))
    );
  }

  filter(value: string): string[] {
    const filterValue = value.toLowerCase();

    return this.countries.filter((country) =>
      country.toLowerCase().includes(filterValue)
    );
  }
}

相关内容

热门资讯

透视计算!aapoker辅助工... 透视计算!aapoker辅助工具,云扑克辅助器苹果,竟然存在有挂(详细辅助黑科技教程)1、aapok...
透视工具!wpk ai辅助,w... 透视工具!wpk ai辅助,wpk透视辅助测试,果然是有挂(详细辅助2025版教程)进入游戏-大厅左...
透视美元局!智星德州菠萝,wp... 透视美元局!智星德州菠萝,wpk系统发牌规律,确实是有挂(详细辅助wepoke教程)1、构建自己的智...
透视脚本!wepoke ai辅... 透视脚本!wepoke ai辅助,德州之星辅助透视,真是存在有挂(详细辅助总结教程);1、起透看视 ...
透视肯定!aapoker外挂,... 透视肯定!aapoker外挂,wpk辅助器是真是假,总是真的有挂(详细辅助透明挂教程);1、完成aa...
透视玄学!微扑克wpk透视辅助... 透视玄学!微扑克wpk透视辅助,德扑之星如何开房间,切实真的是有挂(详细辅助德州论坛)1、微扑克wp...
透视科技!wpk辅助挂,wep... 透视科技!wpk辅助挂,wepok软件透明挂,都是真的是有挂(详细辅助必赢方法)1、打开软件启动之后...
透视app!微扑克游戏辅助器,... 透视app!微扑克游戏辅助器,wpk的发牌有规律吗,其实有挂(详细辅助技巧教程)1、下载好微扑克游戏...
透视app!wpk有外挂,we... 透视app!wpk有外挂,wepoke是机器发牌吗,本来有挂(详细辅助2025新版技巧)1、wpk有...
透视讲解!德扑数据软件,德州w... 透视讲解!德扑数据软件,德州wpk辅助真的,总是真的是有挂(详细辅助AI教程)运德扑数据软件辅助工具...