Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh a page in ionic2

Is there a way to refresh only a page i.e. only one screen in ionic2.

I tried :

window.location.reload();

and

location.reload();

but it rebuilds the app .. is there a way to refresh only that page (particular screen).

Also tried:

<ion-input *ngIf="no_internet === 1" (click)="refresh($event)"></ion-input>

in TypeScript:

refresh(refresher) {
    console.log('Begin async operation', refresher);

    setTimeout(() => {
        console.log('Async operation has ended');
        refresher.complete();
    }, 2000);
}
like image 966
Narendra Vyas Avatar asked Dec 29 '16 06:12

Narendra Vyas


2 Answers

Try this code :

this.navCtrl.setRoot(this.navCtrl.getActive().component);
like image 64
Ahmad Aghazadeh Avatar answered Sep 21 '22 12:09

Ahmad Aghazadeh


You could also use the ionic refresher, to create a pull to refresh action on the page

http://ionicframework.com/docs/v2/api/components/refresher/Refresher/

like image 31
catu Avatar answered Sep 22 '22 12:09

catu