Reputation: 13
I am using Metronic (Angular) theme. I write spinner.show() before calling API. After the API code, I write spinner.hide(). But if an error message is returned from the API service, the error popup stays behind the spinner. How can I hide the spinner automatically if the API service throws an error?
Upvotes: 0
Views: 870
Reputation: 7531
You will never predict when the finalize is executed I'd would advice you stay away form it.
this._sessionService.getCurrentLoginInformations()
.subscribe((sessionInfo: GetCurrentLoginInformationsOutput) => {
if (this.isAdmin(sessionInfo.roles)) {
this.dashboardName = DashboardCustomizationConst.dashboardNames.defaultTenantDashboard;
} else {
this.dashboardName = DashboardCustomizationConst.dashboardNames.defaultTenantUserDashboard;
}
this.loading=true;
this.hide();
},
(err) => {
this.hide();
});
hide() {
this.spinner.hide();
}
Upvotes: 0