I have an Error Management page (parent) that pops up a modal (child). In that modal is a Delete button.
Here is the method for that delete button...
public async deleteAsync(): Promise<void> {
try {
await this.http.delete<any>('https://localhost:7168/api/ErrorManagement/DeleteError/').toPromise();
this.fetchData();
} catch (error: any) {
this.notifyService.showError("Unable to delete " + this.whatYouWantToDelete);
} finally {
// Close the modal
this.bsModalRef.hide();
}
}
After I hit the delete error endpoint, I call the fetchData() method. It is available in the modal because I had sent it from the parent (Error Management page) to the child (modal).
Here is the code for that...
public async fetchDataAsync(): Promise<void> {
try {
window.location.reload();
} catch (error: any) {
this.pageLoadError = JSON.stringify(error.message);
}
}
Right now, I'm using window.location.reload()
to try to refresh the parent (which has a list of the errors) AFTER the child (modal) has deleted one of the errors.
Per my example above, what is the best way to refresh a page (parent) after a modal (child) has closed?