How to detect changes?

Hello guys,

I’m trying to refresh a page if there’s any change in content or activity.

For instance,

IonViewDidLoad() {

if (there's change) {
this.navCtrl.setRoot(this.navCtrl.getActive().component);
}
}

What’s correct command for this?
I’m removing items from favorite list and this needs to be updated whenever I enter this page.

Thanks,

You shouldn’t do this. Angular has a change detection mechanism and will automatically update views to reflect changes in data. If this is not happening, then that is the issue that should be addressed. Typically this kind of thing happens when code is run outside of Angular’s “zone”, and Angular doesn’t know about the change. You can force code to run inside of Angular’s zone by using NgZone, but that should be a last resort - it may just be that your code is not designed in the appropriate way, which is causing change detection to fail.

1 Like

This post includes a good discussion of Angular’s Change Detection System: https://blog.oasisdigital.com/2017/angular-runtime-performance-guide/

And some good links:

1 Like

Hello,
You can read this artcicle. I found there a lot of useful information about Angular changes.