Changing pages two times

Hello.

I have 3 pages (views).

from page1 I can go to page2.

Once I am on page2, I would like that when a user click on a given button

  • it goes back to page1 without the user noticing.
  • go to page3

in order to do that, I wrote in the “button listener”

function actionOnButtonClick(){
$ionicHistory.goBack(); //go back to page1 : appears to not be taken into account
$state.go(‘page3’); //then go to page3
}

This way, if the user is on page3 and click the “back button” (which only calls "$ionicHistory.goBack():wink: he should go back to page1.

My problem is that it’s not the case. it brings him back to page2 exacty as if I had written:
function actionOnButtonClick(){
//$ionicHistory.goBack();
$state.go(‘page3’); //then go to page3
}

I used $stateChangeStart and $stateChangeSuccess to see what is going on and it appears that
when the $ionicHistory.goBack(); is called stateChangeStart is fired but stateChangeSuccess is not.

Can anyone help me do what I want: “go back to the previous page without the user noticing anything and then go to another page in the same function”.

thanks

anyone? I’d like to have some info about that…

hi

why not to code the back button in page 3
to go to page 1

because if I do this, and the user is on page 3 and tap the “back button” he goes to page 1, but then if he uses the back button of his android phone he will go back to page 3… that is not what I want…

hi,

you can use

nextViewOptions()

http://ionicframework.com/docs/api/service/$ionicHistory/

thks you very much this is exactly what I needed.
I just realized that after I posted this question: