首页 > 解决方案 > ng4-autocomplete 如何在 Angular 4 中使用它给我控制台错误

问题描述

我正在使用 ng4-autocomplete,这给了我错误,这是我的代码。

public list = [
    {title: 'Option', id: '1'},
    {title: 'Options', id: '2'},
    {title: 'Optiond', id: '3'},
    {title: 'Optiona', id: '4'},
    {title: 'Optione', id: '5'}
];

constructor(public autoCompleteService: AutoCompleteService ) 
{
    this.setList(this.list);
}

setList(list){
    this.autoCompleteService.filterName = "title";
    this.autoCompleteService.setDynamicList(list);
}

它在控制台中给了我以下错误。请检查我做错了什么。

错误:错误错误:找到对象列表!请提供 filterName 以从对象中提取

这是我的html

<input type="text" [list-length]="10" filterName="title" [word-trigger]="2" no-record-text="No Records Found!" class="form-control" id="list" [ng4-auto-complete]="list">

标签: angularautocomplete

解决方案


我从ng4-auto-complete. 它们不再受支持。建议去PrimeNg


推荐阅读