ng-bootstrap typeahead不会过滤掉任何匹配的结果

时间:2018-02-05 14:28:46

标签: api angular5 typeahead ng-bootstrap bootstrap-typeahead

我在实施ng-boostrap typeahead方面遇到了一些麻烦。 一切都有效,除了过滤。它使匹配的文本加粗,但问题是它不会过滤掉不匹配的结果。

我使用过维基百科样本。

component.html

<input id="typeahead-http" type="text" [class.is-invalid]="searchFailed" [(ngModel)]="model" [ngbTypeahead]="search" [resultFormatter]="formatter" [inputFormatter]="formatter" />

component.ts

search = (text$: Observable<any>) =>
    text$
    .debounceTime(300)
    .distinctUntilChanged()
    .do(() => this.searching = true)
    .switchMap(term =>
    this._genreService.search(term)
        .do(() => this.searchFailed = false)
        .catch(() => {
        this.searchFailed = true;
        return of([]);
        }))
    .do(() => this.searching = false)
    .merge(this.hideSearchingWhenUnsubscribed)

    formatter = (x: {name: string}) => x.name;

service.ts

public search(str): Observable<any> {
    return this._dataService.getAll(`${this._baseApiUrl}/lists/genre`);
} 

0 个答案:

没有答案