Ngbootstrap 错误尝试使用 typeahead angular 10

Ngbootstrap error trying to use typeahead with angular 10

我的代码遇到了问题。我想实现 ngbootstrap 的 typeahead,但我在浏览时遇到了这个错误。

ERROR TypeError: Object(...)(...) is not a function
 at Observable.pipe (Observable.js:85)
 at NgbTypeahead.ngOnInit (ng-bootstrap.js:11786)
 at callHook (core.js:3038)   ..................

我正在开发 angular 10,我正在使用 ngbootstrap 8.0.2 版本

这是我组件中的代码和平

 this.airportService.getAirportsIfExist(airportName)
 .subscribe(result => {
    this.airportList = result;
      if(this.airportList.length==0){
        this.airportListSize = false;
      }
      else{
        this.airportListSize = true;
        this.searchVille = (text$: Observable<any>) =>
          text$.pipe(
            debounceTime(200),
            distinctUntilChanged(),
            map(term => term.length < 1 ? []
              : this.airportList.filter(v => v['name'].toLowerCase().startsWith(term.toLocaleLowerCase())).splice(0, 10))
          )
              }
});

在 html 文件中我得到了这个

    <input formControlName="villeDep" id="departureTown"  type="text" name="town" autocomplete="off" required [ngbTypeahead]="searchVille"/>

我现在不知道发生了什么,文档也没有提供足够的信息。

有人可以帮我 pleeeeeeaaaaaasssssseeeeee 吗???

you need defined searchVille always (not under a subscribe) 所以,声明变量时检查也是 !this.airportList (见评论)

//when you declare the variable
searchVille = (text$: Observable<any>) =>
      text$.pipe(
            debounceTime(200),
            distinctUntilChanged(),
            //see the condition now is "term.length<1 || !this.airportList"
            map(term => term.length<1 || !this.airportList ? []
              : this.airportList.filter(v => v['name'].toLowerCase().startsWith(term.toLocaleLowerCase())).splice(0, 10))
          )