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

77
Visualizações
NgOnInit is not called

I have a page where in my ngOnInit I check from where I arrive (for example, if I arrive from page1 I set a variable that I use to show an html, or from page2 another variable to show another html)

ngOnInit() {
       this.handleParams();
}


handleParams(){
    this.isNewCustomer = JSON.parse(
      localStorage.getItem(LocalstorageKeyEnum.NEW_CUSTOMER)
    );

    let params = this.route.snapshot.queryParams;
    if (params.customerCreate === true) {
      this.customerCreate = true;
    }

    this.isUpdate = JSON.parse(
      localStorage.getItem(LocalstorageKeyEnum.IS_UPDATE)
    );
}

Now I notice that this my ngOnInit() is called only one time, so every time I enter in the page I The handleParams is not checked.

How can I get the ngOnInit called?

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

What is your correct question? Is ngOnInit called once or never? It's correct when it's called just once you entering the page. Maybe your routing to the localStorage is wrong? It's just a simple call - e. g.:

localStorage.setItem('savePage', setUrlFromPage);
const myPage = localStorage.getItem('savePage');
about 4 years ago · Santiago Gelvez Relatório
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