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

143
Visualizações
Angular - window - EventListener - refresh main tab when other close

I use Angular 7. I deal with documents When I click on "INDEXER" button, a second tab is opened with content of the first document and a form. When the form is filled, the second document appears on this second tab etc... When all the documents are ok, this second tab close and and the first main tab must be refreshed.

enter image description here

Code for second tab :

iterate(index) {
this.loadingAction = false;
if (index < this.workflowList.length) {
  this.getDetails(this.workflowList[index]);
} else {
  localStorage.setItem('actualise', 'true');
  window.close();
}
 }

Code for the first tab

 ngOnInit() {
const that = this;

// COMMUNICATION INTER ONGLETS
window.addEventListener('storage', (event) => {
  console.log(event.key)
  // console.log('event storage = LocaleStorage : ' + event.storageArea !== localStorage);
  if (event.storageArea !== localStorage) {
    return;
  }
   if (event.key === 'actualise') {
   // if (event.storageArea.getItem('actualise') === 'true') {
     console.log('appel backend')
     this.refresh();
  } else {
     console.log(localStorage.getItem('actualise'));
   }
});
}

Problem is that backend is called multiple times and when there are a lot of documents, it's very long.

I updated code in order the backend is called one time, it works but the screen is not refreshed

Original : Backend called multiple time and screen refresh

enter image description here

Update: backend called one time but screen is not refreshed

enter image description here

How can I solve that ?

about 4 years ago · Juan Pablo Isaza
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