Reputation: 14998
Every thing work fine in this function, but this.nav.popToRoot() doesn't work in that location. If I move it to the beginning of the function it works correctly. Doesn't any one has a logical explanation for this.
Thank you in advance for your time and consideration.
Here is the code in a booking.ts component:
book(){
let newReservation = {
_id: this.room._id,
from: this.details.from.substring(0,10),
to: this.details.to.substring(0,10)
}
let loading = this.loadingCtrl.create({
content: "Booking room..."
});
loading.present();
this.roomsService.reserveRoom(newReservation).then((res) => {
loading.dismiss();
console.log("Room reserved successfully ... ");
this.nav.popToRoot();
}, (err) => {
console.log(err);
});
}
Upvotes: 2
Views: 4036
Reputation: 2049
It happens the same to me, but i managed to replace the whole history stack, in my case after a certain point i don't need to keep the history stack, this is how i did it:
this.navCtrl.setPages([
{ page: RootPageHere }
]);
Works inside of a promise then function.
Upvotes: 8