Change back button href in controller?


#1

I have a page that have 3 level, when my user reached the last page (3rd level) I want to change the back button so that the user will go back the first level if clicked. Because by default it will go the second page.

//what should I do before or after this code?
$state.go(‘app.mythirdPage’);


#2

Inject $ionicHistory inside the controller of that view and use $ionicHistory.goBack(-2) to go back two views.

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


#3

I don’t want to go back programmatically, I want to set the back button’s target when user clicked on it.