#Filter By ID
2 messages · Page 1 of 1 (latest)
(1) this.bankService.fetchAllBanks().subscribe(res =>
(2) this.bArray=res
);
(3) this.bArray.filter(obj => obj.customerId===this.cid);
beware of asynchronous code
(1) is asynchronous code
it executes code whose response will come a few milliseconds later (http, ...)
(3) it filters this.bArray but this one is empty
(2) a few milliseconds later: this.bArray=res is executed !
do you see the problem ?