我想为按钮添加加载状态,但我不想为它提供任何服务。我对管道感到非常困惑,而且我不了解正确的语法。当 this.apiService.exportReport 完成时,我可以将 isLoading 设置为 false 吗?
public exportReportResults(format: ExportFormat) {
this.isLoading = true;
this.sink.add(
this.service.context.pipe(
filter((value) => !!value))
.subscribe(
(data) => {
const items: any[] = [];
data.context.groups.forEach(function (group) {
items.push(group.items.map(({ id }) => id));
});
const itemQuery: string = "'{" + items.toString() + "}'";
this.apiService.exportReport(format, itemQuery);
this.isLoading = false; //not good this way of course
},
)
);
}