getBudgetMap(budgetMonthID){
this.rows = [];
this.categoryService.getCategory(budgetMonthID).subscribe(category =>{
this.categoryList = category;
this.categoryList.forEach(category => {
this.transactionService.getTransaction(budgetMonthID, category.id).subscribe(transaction => {
this.rows = this.rows.concat(transaction);
})
})
)
}
To make it easy, I have a nested ajax service (http.get) call which the first one (getCategory)
returning a list of category base on budgetMonthID
. The number of categories varies. Then each category will make a second call getTransaction
to retrieve all transactions belong to each category. The code above works fine, but I been reading about map
, flapMap
, pipe
for Angular, I just can't figure it out how to change that nasty code. Thanks