This returns the dropdown options available to be displayed. I'm assuming the problem is with the .pipe but I can't seem to correct it.
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;
});
});
} ```
CodePudding user response:
Because your service method returns a Subscription
, not an observable. You should use the map
operator in your service method and not .subscribe
to the observable there.
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;
});
})
);
}