我要从Selected服务选择器获取ID和ova,并想将其解析为一个调用方法中的API端点的GET方法。 这就是我所做的,但是在记录数据时,在选定的服务页面负载上,我得到的是空值。需要帮助。
@Effect()
loadService$ = this.actions$.ofType(servicesActions.LOAD_ONE_SERVICE)
.pipe(
switchMap(() => {
this.store.select(fromSelect.getSelectedService).subscribe(
data => {
this.id = data.merchantId,
this. ova = data.ova
}
)
return this.appservice
.getServiceById(
this.id,
this.ova
)
.pipe(
map(service => new servicesActions.LoadServiceSuccess(service)),
catchError(error => of (new servicesActions.LoadServiceFail(error)))
);
})
);
答案 0 :(得分:0)
您可以尝试类似的方法。使用switchmap在管道中保留一层嵌套。
@Effect()
loadService$ = this.actions$.ofType(servicesActions.LOAD_ONE_SERVICE)
.pipe(
withLatestFrom(this.store.select(fromSelect.getSelectedService)),
switchMap(({merchantId, ova}) => this.appservice.getServiceById(merchantId, ova))
.pipe(
map(service => new servicesActions.LoadServiceSuccess(service)),
catchError(error => of(new servicesActions.LoadServiceFail(error)))
)
);