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有辅助工具吗,wepoker有没有辅助(透视)确实真的有挂(哔哩哔哩)1、w...
透视手筋!如何判断wpk辅助软... 透视手筋!如何判断wpk辅助软件的真假,werplan透视挂(透视)一贯存在有挂(哔哩哔哩);小薇(...
透视操作!pokerworld... 透视操作!pokerworld破解版下载,wepoker有机器人吗(透视)真是存在有挂(哔哩哔哩)1...
透视步骤!wpk插件,大菠萝手... 透视步骤!wpk插件,大菠萝手游辅助(透视)都是有挂(哔哩哔哩)1、完成大菠萝手游辅助辅助器v3.3...
透视指引!wepoker手机助... 透视指引!wepoker手机助手,epoker透视(透视)本来真的有挂(哔哩哔哩);该软件可以轻松地...
透视方式!德州hhpoker脚... 透视方式!德州hhpoker脚本,wepoker数据分析(透视)真是真的是有挂(哔哩哔哩)wepok...
透视课程!wepoker安装教... 透视课程!wepoker安装教程,epoker有透视吗(透视)本来是有挂(哔哩哔哩)1、操作简单,无...
透视窍门!hhpoker外开挂... 透视窍门!hhpoker外开挂靠谱吗,wepoker插件辅助(透视)都是是有挂(哔哩哔哩)1、该软件...
透视教程书!wepoker脚本... 透视教程书!wepoker脚本,wepoker免费脚本弱密码(透视)竟然真的有挂(哔哩哔哩)1、每一...
透视诀窍!德州透视是真的假的,... 透视诀窍!德州透视是真的假的,hhpoker哪个俱乐部靠谱(透视)都是是有挂(哔哩哔哩)1、透视诀窍...