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

786
Visualizações
How to reload the current page on click of a button in ionic 2?

I have a requirement where I have refresh the contents of the current page onclick of the refresh button in the current page.I went through few websites but I am not quite clear about this functionality.Could anyone suggest me how to do this?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Onclick of your refresh button, you could call the page event method ionViewWillEnter()

From the official docs --> ionViewWillEnter() Runs when the page is about to enter and become the active page.

HTML

<button (click)="refreshPage()">Refresh Page</button>

Typescript

    ionViewWillEnter(){
            this.myDefaultMethodToFetchData();
        }

    refreshPage() {
        this.ionViewWillEnter();
    }

    myDefaultMethodToFetchData(){
        ...Do Something, when the page opens...
    }
over 4 years ago · Santiago Trujillo Relatório

0

This will work!!! Give this under the function that's called on button click event.

this.navCtrl.setRoot(this.navCtrl.getActive().component);

or

Use the ionViewWillEnter lifecycle event on your page. You can put the correct code in that method to refresh all the necessary things on your page. https://ionicframework.com/docs/api/navigation/NavController/

over 4 years ago · Santiago Trujillo Relatório

0

Add this in the constructor and just replace your page name

    this.navigationSubscription = this.router.events.subscribe((e: any) => {
           if (e instanceof NavigationEnd && e.url === '/page-name' && localStorage.getItem('prevUrl') === '/page-name') {
            this.ionViewWillEnter();
            this.ngOnInit
           }
        });

over 4 years ago · Santiago Trujillo 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