Vanddel Vanddel - 1 month ago 15
TypeScript Question

scrolling in ionic2 is disabled when I navigate from a popover to a page

Ionic2 disables scrolling in a page if I'm navigating to it from a popover, the problem details is as follows:

I have 3 pages, one is timeline that has this code:

let popover = Popover.create(ItemListPage, {items: data.data});
this.nav.present(popover);


as shown in the code timeline calls a popover: ItemList, which has this code:

close() {
this.viewCtrl.dismiss();
}

showUserProfile(user){
this.close(); //I added this line to check if the popover is the reason
this.nav.push(UserProfilePage, { userToShow: user});
}


as shown in the code, when a click event happens on an item in the popover, the showUserProfile function is called, it closes the popover(which I only added this line to check if the popover is the reason of the error), and then navigates to another page: UserProfilePage.

in UserProfile page, I have a scroller, which works fine in all cases except for this one when I navigate to UserProfilePage from the itemListPage popover. In this case the scroller only works if I replaced the
this.nav.push(UserProfilePage, { userToShow: user});

with

this.nav.setRoot(UserProfilePage, { userToShow: user});


I'm not sure why this happens, and what can I do to fix it.
PS: I don't want to close the popover, I want the user to go back to it, I just added it to check the error reason.

Answer

this.viewCtrl.dismiss(); returns a promise, so the correct usage should be:

close() {
   return this.viewCtrl.dismiss();
 }
 showUserProfile(user){
   this.close().then(data =>{
       this.nav.push(UserProfilePage, { userToShow: user});
   });
 }
Comments