Creating a tab that doesn't store any navigation history


#1

Hi there,

How could I avoid storing any navigation history for one particular tab?

To give a concrete use case, one of my tabs is “log your mood”. It takes them to a page with a mood widget, and then from there to a calendar of their past moods. Every time a user goes back to this tab, I would like them to start by logging their mood. Every time they visit, it should be just like the first time. I need this particular tab to have navigation amnesia.

Is this possible? Any tips?


#2

SetRoot method of navController seems to clear the history, as in no back button, it might serve your needs.


#3

Hi Tal,

Thanks for the pointer. For anyone else facing a similar issue, I ended up solving it by doing the following (when the user hits “finish” at the end of the page sequence for the amnesiac tab)

//set root to be the first page you want people to see when they revisit the tab
//don't animate the transition, otherwise that page will flash up for a second before going away
this.navCtrl.setRoot(MoodgaugePage, null, {animate:false})
        .then(() => {
            //go back to the tab people were on before they entered the amnesiac tab.
            this.tabs.select(this.tabs.previousTab(true)) ;
        })