How to remove "ION-TAB" from $rootScope.$viewHistory


#1

Hello, I am having a requirement where i need to skip all “ion-tab” from navigation history. Is there any way I can do this?

Example - Say, in my app i had a screen where it has 5 tabs. User can select any tab any time, But when he click on “Back” button I should take the user to previous page not previous tab.

Any input.?


#2

As I understand it, each tab should already maintain its own separate history stack, so tapping back shouldn’t move you from one tab to another unless there’s something peculiar with your routes.


#3

hmm, looks like I confused you. Here is screen shot explains my requirement.

Screen 1 - “Unscheduled” - When user selects any list item it will take user to Screen2.

Screen 2 - “2009 Nissam Ultima” - Contains 5 tabs. User can navigate to any tab in screen 2. But when user click on “back” button I should take him to “Screen1”.

Currently when I click on back button it was taking to previous tab. But I need user to completely navigate to previous screen.

Any idea?


#4

From the docs ( http://ionicframework.com/docs/api/directive/ionNavBackButton/ ) you can set ng-click on ion-nav-back-button, so it might work to write a custom method that when the back button is clicked, you use $state.go to jump back to Screen1.


#5

@thechrisroberts - It actually not that straight forward. I just illustrated an example.

In my case user can navigate to “Screen 2” from multiple ways. may be from Screen 1, may be from screen 3 (Which is not in above example). The best thing I should do is when ever I am in “Screen 2” - I should store previous screen (either “screen 1” or “Screen 3” or “Some other Screen”).

But it is not best practice. Do you suggest any other way?