0
我有遵循此逻辑可观察的链:getStyles() - > getPrices()可观察链重演
对于每CONFIGS config.id,_APIService.getStyleByID()返回称为“风格对象资源”,这种风格对象被传递到价格追加到它,是getLease(),然后按下称为数组‘车库’
getStyles(configs: any) {
configs.forEach(config => {
this._APIService.getStyleByID(config.id).subscribe(
res => {
res.config = config;
this.getLease(res);
}
);
});
}
getLease(style: any): void {
this._priceService.getPrice().subscribe(
price => {
style.price = price;
this.garage.push(style);
console.log(this.garage);
});
}
}
我遇到的问题是,有上正在做一个循环_APIService.getStyleByID。如何解决我的Service方法只能在每个配置中调用一次? (它递归过的CONFIGS阵列两个三倍以上。