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

相关内容

热门资讯

WPK安卓演示!wepoker... WPK安卓演示!wepokerplus到底是挂了吗,德州微扑克一直存在有辅助器方法1、上手简单,内置...
WPK脚本方针!wepoker... WPK脚本方针!wepoker免费钻石,德州微扑克切实存在有辅助器脚本1、全新机制【wepoker免...
WPK透视烘培!wepoker... WPK透视烘培!wepoker底牌透视脚本,德州微扑克本来存在有透视工具1、这是跨平台的wepoke...
WPK德州局方式!wpk脚本辅... WPK德州局方式!wpk脚本辅助器,德州微扑克切实是有辅助软件1、超多福利:超高返利,海量正版游戏,...
WPK控制牌秘籍!wepoke... WPK控制牌秘籍!wepoker透视脚本,德州微扑克确实是真的有辅助器攻略wepoker透视脚本脚本...
WPK控制牌教程书!wepok... WPK控制牌教程书!wepoker怎么提高运气,德州微扑克竟然是真的有辅助器技巧1、进入游戏-大厅左...
WPK透视总结!wepoker... WPK透视总结!wepoker底牌透视脚本下载,德州微扑克竟然存在有辅助方法wepoker底牌透视脚...
WPK工具烘培!wepoker... WPK工具烘培!wepoker辅助是真的吗,德州微扑克总是有辅助器神器1、wepoker辅助是真的吗...
WPK安装总结!wepoker... WPK安装总结!wepoker透视脚本安卓,德州微扑克真是真的是有开挂神器1、每一步都需要思考,不同...
WPK安卓窍门!wepoker... WPK安卓窍门!wepoker安装教程,德州微扑克竟然有透视教程1、WPK安卓窍门!wepoker安...