_
_
_ _2014-11-10 20:39:56
Angular
_ _, 2014-11-10 20:39:56

Ionic Framework, ui-router - how to defeat navigation in tabs?

There is an application with tabs.
The hierarchy of states of one of the tabs looks like a trace. way.
tab.common - an abstract state, needed to store data common to all child states tab.common.step1
tab.common.step2
The
tab itself contains the link "#/tab/common/step1"
I get to step1. I do things there, by clicking I go to step2 (via $state.go). From state2 through $state.go I go to another tab.
Attention - the question is: why, when I want to go to /tab/common/step1 again by clicking on a tab, does it immediately send me to /tab/common/step2?
I understand that ionic tabs store state, but how do you tell them to forget it at some point?
On the other hand - maybe there is some other option to store common data for child states? I need step1 and step2 to have the same parent scope.
PS I invite Sergey Protko to the thread
PPS

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2014-11-10
@AMar4enko

In general, if anyone is interested, I can write what decision I came to.
UPD. The solution is:
1. Use $ionicViewService.clearHistory to clear the navigation history inside the ion-nav-view.
When I go to step 1 in my example, then acc. controller at the very beginning I clear the history, when exiting from step 2 to another tab, I also clear the history. The service determines which stack to clear based on the visible views.
2. Don't use href in ion-tab. He processes them somehow in his own way, in order to activate the tabs.
Those. if you write href="#/tab/common/state1" and in the tab state state2 was once activated, then this tab will be activated and state2 will be displayed, although state1 was requested.
If you do $state.go('tab.common.state1'), then state1 will be displayed, but only when the tab is already active! This follows from the third point.
3. Deep Linking doesn't work with tabs. Those. if you cold start the application with url #/tab/common/step1, which is displayed in the second tab, then nothing will happen, because the first tab will be active at startup. Here the dude faced the same thing
https://github.com/driftyco/ionic/issues/2442. I solved this issue head-on by hanging a controller on the tabs themselves, in which, based on the current state, I manually activate the desired tab through $ionicTabsDelegate.
PS The behavior, as in my example, which did not suit me, is correct, here is a factory example codepen.io/ionic/pen/odqCz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question