Ionic Refresh Current Page

Worked like a charm ! Thanks !!!

can you please look at this problem , and guide me towards the correct solution.
this is a situation that I really need to force refresh or reload the list in the page.

It’s working. Thank you :slight_smile:

I’m with a problem that when I read via bluetooth an code, I add a value to a variable shown on the screen. The value change but the view just refresh when I press any button. Anyone have a solution to this?

this.navCtrl.setRoot(this.navCtrl.getActive().component); it’s not the solution :sob:. It removes all previous navigations.

I’m showing a value that changes when I read a bluetooth code. It works perfect, but the variable do not change on screen, it just change when I press any button on the screen. Someone have a solution to this?

2 Likes

To solve my problem I used this How to properly re-render a component in Ionic manually

1 Like

I read through a bunch of these solutions and really none worked for me.

ionic --version
3.13.0

Since the page is a basically a view

I added to constructor
private viewCtrl: ViewController

make sure to
import {ViewController} from ‘ionic-angular’;

I’m using

ionViewDidEnter()
to as my main view event refresh

So when I was calling a delete function like

onRemoveItem(idx:number) {
      this.someStorageProvider.deleteItem(idx);
          this.someStorageProvider.getItemList().then(res => {
      this.currentList = res;
      this.viewCtrl._didEnter(); //<---- this is what dis the trick
    });

The ViewController can trigger an
ionViewDidEnter
by
_didEnter() method

this force refresh on my

<ion-list *ngIf=“currentList.length > 0” >

Hope this helps…

2 Likes

https://angular.io/guide/displaying-data

You can try window.location.reload()

Don’t do reload(), it messes things up down the road like sqlite plugin and possibly other internal states outside the webview

If there is a problem with change detection by angular (which may also indicate a design issue), wrap your stuff in a zone so angular knows what to monitor.

Dont go calling internal onWillEnter etc.

somehow doesn’t seem to work, this was my first attempt too…

Someone buy Beer For @dupinder … works like champ

Pull-to-Refresh

Guys, checkout this helpful video I found which shows how to do pull-to-refresh a page in ionic application: https://youtu.be/LBZQ-jHuQq0

Auto-Refresh on Event Triggering

Add the following code by @dupinder:

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

2 Likes

HugoPetla, maybe look at zones…
I had same issue with bluetooth app specifically.

Worked like a charm for me :smiley:

Do you need a beer? :*

this.navCtrl.setRoot(this.navCtrl.getActive().component); is work fine in android but not working on IOS for me. when we use for IOS app is going to Crashed .
Please Help

Its dirty hack but it does what I need (to reset a file input which honestly also wasn’t 100% member of the Angular loop). Thank you.

import {Content} from 'ionic-angular';
@Component({
.... 
})

export  default class HomePage extends Component{

 @ViewChild(Content) content:Content;


//binded for any event (click,onChange ...)
updateContent(){
   
//recalculate everything on current page; 
  this.content.resize();
}

}

ionViewDidEnter() work for me! Ty