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)
    );
  }
}

相关内容

热门资讯

透视安卓版!wepoker有什... 透视安卓版!wepoker有什么规律(透视)好像有挂(详细辅助透明教程)1、进入游戏-大厅左侧-新手...
盘点十款!wepoker透视脚... 盘点十款!wepoker透视脚本苹果版,wpk作弊最怕三个东西,分享教程(有挂神器)1、许多玩家不知...
透视系统!aapoker插件(... 透视系统!aapoker插件(透视)原来真的是有挂(详细辅助AI教程)运辅助工具,进入游戏界面。进入...
必备辅助推荐!aapoker怎... 此外,数据分析德州(hhpoker辅助软件是真的么)辅助神器app还具备辅助透视行为开挂功能,通过对...
透视数据!hhpoker作弊实... 透视数据!hhpoker作弊实战视频(透视)竟然真的有挂(详细辅助解说技巧);1、系统规律教程、辅助...
透视真的!xpoker辅助器(... 透视真的!xpoker辅助器(透视)一直有挂(详细辅助解密教程)1、下载好辅助软件之后点击打开,先需...
重要通知!佛手大菠萝13道挂哪... 1、重要通知!佛手大菠萝13道挂哪里,wepoker有辅助吗,扑克教程(有挂透视);详细教程。2、佛...
透视有挂!hhpoker有没有... 透视有挂!hhpoker有没有作弊辅助(透视)其实真的有挂(详细辅助AI教程)透视有挂!hhpoke...
重大通报!hhpoker哪个俱... 重大通报!hhpoker哪个俱乐部靠谱,德州辅助工具到底怎么样,微扑克教程(有挂透视);小薇(透视辅...
透视数据!wpk俱乐部辅助器(... 透视数据!wpk俱乐部辅助器(透视)确实存在有挂(详细辅助wepoke教程)1、上手简单,内置详细流...