How to handle data comes late from service?
问题 In my angular application, i am in the need to store the data to an array which will be empty at initial stage. Example : someFunction() { let array = []; console.log("step 1"); this.service.getRest(url).subscribe(result => { result.data.forEach(element => { console.log("step 2"); array.push(element); // Pushing all the objects comes from res.data }); console.log("step 3"); }); console.log("step 4"); } Here i have listed down the console.log() with step order. In which the order while calling