I am using Angular 7 and facing an issue => after login the API GET calls successfully and the component receiving data too, but UI is not displaying that data.
Whe
Usually this happens when you are wrapping angular calls inside some external js callback, from external JavaScript not related to angular code.
Example app.component.ts
:
callMyCustomJsLibrary() {
googleSdk.getLocations(location => this.getEmployees());
}
getEmployees(): void {
this.employeeService.getEmployees().subscribe(e => {
this.employees = e;
});
}
In this case you will have to include the call into the NgZone, example:
this.ngZone.run(() => this.getEmployees());
The app.component.ts
would then look like the following:
callMyCustomJsLibrary() {
googleSdk.getLocations(location => this.ngZone.run(() => this.getEmployees()));
}
getEmployees(): void {
this.employeeService.getEmployees().subscribe(e => {
this.employees = e;
});
}