pcyuen98 / covidAngular

0 stars 0 forks source link

KT Alternative way to synchronous variable in practical 9 #8

Closed KahouTong closed 3 years ago

KahouTong commented 3 years ago

async ngOnInit(): Promise { this.descObject = {}; this.updateDesc = {}; this.postDesc = {}; await this.getCovidInit(); this.descObject = this.temp; this.getCovid(); this.getCovidDesc(); console.log("Covid Component Inited"); console.log("Total of Description Column Row --->" + this.descObject.length); }

async getCovidInit(): Promise { return this.descObject = await this.covidApiService.getCovidDesc().toPromise().then((data: any) => { this.temp = data; }); }

For further understanding: https://balramchavan.medium.com/using-async-await-feature-in-angular-587dd56fdc77