为什么会出现此错误?管道不是函数

Why am I getting this error?pipe is not a function

此 returns 可显示的下拉选项。我假设问题出在 .pipe 上,但我似乎无法更正它。

        return this.lasService.getLasDropDownOptions(true)
          .pipe(takeUntil(this.unsubscribe))
          .subscribe((lasOptions) => {
            return resolve(lasOptions.map((option) => {
              return option || [];
            }));
          });
      }
   

 getLasDropDownOptions(refresh) {
    return this.getLasData(refresh)
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((response) => {
        return response.map((las) => {
          las.displayValue = las.name + ' - ' + las.expression;
          if (!las.status) {
            las.disabled = true;
            las.category = 'Calculating';
          } else {
            las.category = las.longterm ? 'Online Range' : 'Short Term';
          }
          return las;
        });
      });
  } ```

因为您的服务方法 returns 是 Subscription,不是可观察的。您应该在服务方法中使用 map 运算符,而不是对那里的可观察对象使用 .subscribe

getLasDropDownOptions(refresh) {
  return this.getLasData(refresh).pipe(
    takeUntil(this.unsubscribe),
    map((response: any[]) => {
      return response.map((las) => {
        las.displayValue = las.name + " - " + las.expression;
        if (!las.status) {
          las.disabled = true;
          las.category = "Calculating";
        } else {
          las.category = las.longterm ? "Online Range" : "Short Term";
        }
        return las;
      });
    })
  );
}