• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

377
Views
Best way to refresh parent component in Angular

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?

about 3 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error