Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

angular

ionic2

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?

like image 787
akila arasan Avatar asked Mar 10 '23 05:03

akila arasan


1 Answers

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...
    }
like image 107
Manoj Negi Avatar answered Apr 25 '23 21:04

Manoj Negi