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



这将返回可显示的下拉选项。我想问题出在管道上,但我似乎无法纠正。

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;
});
});
} ```

因为您的服务方法返回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;
});
})
);
}

最新更新