angular2 services - Implement ngDoCheck when a list object change on angular 2 -


in case have function , inside calling nested api in loops. want call function when calls completed inside loops. calling function outside loop called before completion of loop.did use ngdocheck checking continuously.

this code

this.cmsservice.listservicebyproductandparentservice(productid,parentserviceid).subscribe(servicelist=>{                 for(let i=0;i<servicelist.length;i++){                      if(servicelist[i].has_children){                            this.cmsservice.listservicebyproductandparentservice(productid,servicelist[i].id).subscribe(services=>{                                for(let j=0;j<services.length;j++){                                    this.cmsservice.listpricebyserviceid(productid,services[j].id).subscribe(res=>{                                        servicelist.push(res);                                     })                                }                           })                           console.log("removed service list is",servicelist[i]);                           servicelist.splice(i,1);                     }                     else{                         this.cmsservice.listpricebyserviceid(productid,servicelist[i].id).subscribe(pricelist=> {                              servicelist[i]=pricelist;                         })                     }                 }                 console.log("servicelist is",servicelist);                 this.services=servicelist;                   this.doreset();              this.doinitadd();             }) 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -