Passing data back from nav.pop()

I did nothing else than the solution provided by @Jeffroylance in the post I listed above…

Gonna copy his answer here:

myCallbackFunction = (_params) => {
 return new Promise((resolve, reject) => {
     this.test = _params;
     resolve();
 });
}

// push page...
functionToBeClicked() {
    this.navController.push(OtherPageComponent, {
        callback: this.myCallbackFunction;
    });
}

and in the other page (in this example would be “OtherPageComponent”)

 ionViewWillEnter() {
      this.callback = this.navParams.get("callback")
 }

 ionViewWillLeave() {
    this.callback(param).then(()=>{
       this.navController.pop();
   });
}
8 Likes