$state.go() problem. I NEED HELP!


#1

Is it possible for $state.go("") not to push new view to the right?

I have sidemenu with menu item 1 and menu item 2.

I have a button that will do $state.go(menu1) within menu item 2’s view, and rather than push new view to the right, is it possible to just directly go to menu item 1’s view?

Hope that make sense… Here is drawing that will help.


#2

In case of that you need to set the nextViewOptions with the $ionicHistory-Service, before you are routing to menu1view.

$ionicHistory.nextViewOptions({
  disableAnimate: true,
  disableBack: true,
  historyRoot: true
});
$state.go('menu1view');

so you have no page transition --> because your states are on the same level in your navigation structure --> because they are on Level1 --> you do not need a backbutton --> and because of that menu1view should become the new historyRoot :slight_smile:


#3

Great, will try that and let you onow what i come up with


#4

@bengtler would this apply to the whole app!?

It seems like it did not for me.? Should i make the setting to go back to default?


#5

This sets those options only for the next state change.

so you have to set a ngClick to your button, that redirects to menu1view.
In this function you do the stuff i posted in my last post ($ionicHistory.nextViewOptions(…)…).


#6

@bengtler but how do you know its only for 1 time state change with the code? Btw its working great.


#7

because thats how the function nextViewOptions() works and is intended to work :wink: