我在维基百科搜索中可以看到
https://ng-bootstrap.github.io/stackblitzes/typeahead/http/stackblitz.html
export class NgbdTypeaheadHttp {
model: any;
searching = false;
searchFailed = false;
myfilter = ['Mary' , 'Maryland'];
constructor(private _service: WikipediaService) {}
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(300),
distinctUntilChanged(),
tap(() => this.searching = true),
switchMap(term =>
this._service.search(term).pipe(
tap(() => this.searchFailed = false),
catchError(() => {
this.searchFailed = true;
return of([]);
}))
),
tap(() => this.searching = false)
)
}
在管道中的Switchmap运算符之后,我想过滤掉响应。
要过滤的项目存储在myFilter列表中。
我对如何做到这一点感到困惑。