There is a cell in the grid that displays the number of users for each company. This number is retrieved from a TypeScript method called getNumberOfUsers(), which makes a call to a Back-End web service to fetch the user count. However, all cells are showing 0, even though the getNumberOfUsers() method correctly logs the number of users in the console.
<tr>
<td>
{{ getNumberOfUsers() }}
</td>
</tr>
Component TypeScript file
getNumberOfUsers(): number {
let NumUser = 0;
this.callServices.getUserCount().subscribe((res: any) => {
NumUser = JSON.parse(res._body).numberOfUser;
Console.log(“NumUser=” + NumUser)
},
(err) => console.error(' getUserCount::err==' + err)
);
return NumUser;
}
CallService file
getUserCount(): Observable<any> {
return this.http.post(this.apiUrl+'/getUserCount');
}
I am looking to convert this method into a synchronous one