How to reload the current page on click of a button in ionic 2?

14,896

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...
    }
Share:
14,896
akila arasan
Author by

akila arasan

Updated on June 26, 2022

Comments

  • akila arasan
    akila arasan almost 2 years

    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?