When I hit an api to get data from server in constructor and store it in local variable. I loop this variable in html to build table and show data in table. But when I call a function on api success and in it I loop the same variable which is used in HTML, the loop in function will run first and after that HTML loop. My requirement is to run HTML loop first and after its completion loop in function.
HTML CODE
<table>
<tr *ngFor="let booking of jobHistory>
<td>{{booking}}</td>
</tr>
</table>
TYPESCRIPT CODE
jobHistory : any;
constructor()
{
this.service.getCustomerJobHistory().subscribe( res => { this.jobHistory = res},
err => console.log(err),
() => this.setRating()
);
}
setRating()
{
//I want to run this loop after HTML loop completion.
for(let booking of this.jobHistory)
{
console.log(booking);
}
}