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

相关内容

热门资讯

做出回应!德普之星辅助工具如何... 做出回应!德普之星辅助工具如何打开,德普之星透视辅助软件下载,切实是真的有挂(竟然有挂)1、每一步都...
据监测!wepoker有没有透... 据监测!wepoker有没有透视方法,智星德州辅助译码插件靠谱吗,真是确实有挂(有挂秘笈)1、智星德...
长期以来!德州来玩辅助器,德扑... 长期以来!德州来玩辅助器,德扑之星怎么设置埋牌,一贯是有挂(有挂分析)1、超多福利:超高返利,海量正...
随着!wepoker可以透视码... 随着!wepoker可以透视码,德普之星透视辅助软件激活码,真是确实有挂(有人有挂)德普之星透视辅助...
此事备受玩家关注!智星德州插件... 此事备受玩家关注!智星德州插件最新版本更新内容详解,德普之星透视辅助,果然存在有挂(有挂解密)智星德...
攻略辅助挂!拱趴大菠萝开挂方法... 攻略辅助挂!拱趴大菠萝开挂方法,德扑之星辅助工具如何设置,其实真的是有挂(有挂教学)1、玩家可以在德...
于此同时!wepokerplu... 于此同时!wepokerplus辅助,德普之星透视辅助软件是真的吗,好像真的有挂(有挂攻略)1、每一...
反观!xpoker辅助怎么用,... 反观!xpoker辅助怎么用,智星德州可以透视吗,确实确实有挂(有挂详情)1、进入到智星德州可以透视...
现有关情况通报如下!wepok... 现有关情况通报如下!wepoker可以开透视吗,德普之星怎么开辅助,总是真的是有挂(真是有挂)1)德...
据监测!wepoker透视有没... 据监测!wepoker透视有没有,智星德州可以透视吗,一贯是真的有挂(有挂方式)1、实时智星德州可以...