$ state.go does not work with 3rd level nested state (using Ionic / AngularUI tabs)

I am trying to use $state.goIonic (+ AngularJS UI Router) to switch between tabs in an application, but I cannot get it to work with a sub-state (state.substate.subsubstate). In fact, it works great when switching to a sub-state (state.substate).

Here is what I mean: http://codepen.io/anon/pen/Jykmi?editors=101
Pressing the Tab2 button does not work and does not throw an error. However, replacing ng-click="goToState('tabs.tab2.home1')"(line 25) with ui-sref="tabs.tab2.home1"or href="#/tabs/tab2/home1"works fine. Here is an example: http://codepen.io/anon/pen/DIxhC?editors=101

Even use ng-click="goToState('tabs.tab2')"will work, although this is not the target state of the target.

I found other similar questions (like this one and this one ), but I don’t think they had the same problem.

Does anyone know if it should $state.gowork with nested states of the third level ?. Is there a problem in my code?

Thank you in advance. Sincerely,
   . Rafa

+4
source share
2 answers

How to ui-sref="tabs.tab2.home1"use internally $state.goand, as you said, ui-sref="tabs.tab2.home1"works.

My answer is yes: it $state.go()should work with nested states of the third level.

I really use it in my own project without problems (but without ion tabs)

+1

, , .

, : href ui-sref , ng-click $state.go ( , ). , :

html:

ui-sref="tabs.tabs2.home" + ng-click="goHome()" 

href="#/tabs/tabs2/home" + ng-click="goHome()" 

js:

$scope.goHome = function(){
    $state.go('tabs.tabs2.home');
    // or, location.path works fine too:
    // $location.path('/tabs/tabs2/home');
}

,

+1

Source: https://habr.com/ru/post/1547838/


All Articles