Clear Screen after Transition - IONIC app

Asked

Viewed 397 times

1

I’m creating an app with Ionic and angular, and I’m making use of tabs. I have 5 tabs, and one of them displays a "Menu" page, this page contains the listing of other pages that are not in tabs, each item of this listing redirects to a different page.

My problem is that when I click on the Menu tab, it displays the listing and I select the page I want to go to, but if I click on another tab, and then click on the Menu tab again, it will no longer list the items, and yes it will display the last page I had accessed through the Menu.

To be clear: click on the Menu tab/ I see the list of items/ I select the Clients/ I am redirected to the Customers page/ when I click on another tab (example: Products), I am redirected to Products/ but when I click on the Menu tab again, it does not display the page with the items, but rather the Customers page, which I had previously accessed.

I don’t think there is an error in my code, but I wonder if there is any function of Ionic that can use to make this "clean" after leaving the page, I tried to use ionViewDidLeave, but it did not work.

  • What’s happening is that you’re not finishing the component when you’re switching tab. Ionic has some life cycle methods. (Take a look) https://blog.ionicframework.com/navigating-lifecycle-events/ .... If you use it you could close the previous component on ionViewWillLeave with the Navcontroller pop method... I have an example on this page: https://github.com/brognilucas/top-weather/blob/master/src/pages/city-details/city-details.ts

  • I created ionVieWillLeave() inside the Menu ts, but it didn’t work. ionVieWillLeave(){ this.navCtrl.popToRoot(); }

  • Martin, try to put a log console in ionViewWillLeave? It may be that it is not calling because it is just a tab change.

  • the console log is working normally, the problem would not be this.navCtrl.popToRoot() ?

  • Try to give only one navCtrl.pop() other than root ... I thought it was not entering the screen output method. If it doesn’t work only with pop I don’t know now what it can be :(

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.