For your task, you can also use ion-nav-view .
This is well documented. And if you are using the beta version of Ionic 2, you can use some of them, for example, onPageWillLeave() or onPageWillEnter() . I just ran into the same problem and defined the refresh () function, but the user had to click on the button to actually refresh the view. But then I discovered:
https://webcake.co/page-lifecycle-hooks-in-ionic-2/
You just need to import the page module and NavController, and also define it in the constructor. You can use, for example, onPageWillEnter (), which will always be called upon re-viewing:
onPageWillEnter() { // Do whatever you want here the following code is just to show you an example. I needed it to refresh the sqlite database this.storage.query("SELECT * FROM archivedInserates").then((data) = > { this.archivedInserates =[]; if (data.res.rows.length > 0) { for (var i = 0; i < data.res.rows.length; i++) { this.archivedInserates.push({userName:data.res.rows.item(i).userName, email: data.res.rows.item(i).email}); } } },(error) =>{ console.log("ERROR -> " + JSON.stringify(error.err)); }); }
With ion beta 8, lifecylcle events changed their names. Check out the official ion block for a complete list of life cycle events.
source share