Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

440
Visualizações
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 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda