Looking at http://ionicframework.com/docs/api/directive/ionNavView/ if you click on the Scientific Facts button, then click on the More Facts button, there is a button to get back to Home. But you’ll notice when doing so the Home page/view show is not the Home we started at. It has a back button (Also Factual). My question is how would one go back to the initial state/page and lose the navigation history on purpose?
Found my answer within this thread - http://stackoverflow.com/questions/27930702/ionic-framework-state-goapp-home-is-adding-back-button-on-page-where-i-wan.
I used the suggestion to run the statement below before hitting $state.go(). Ensure to inject the $ionicHistory service in the controller.
$ionicHistory.nextViewOptions({disableBack: true});
if you are on your “root”-state call:
$ionicHistory.clearHistory()
It will clear ionic navigation history.
i am doing this like in a base-controller for my app:
$rootScope.$on('$stateChangeSuccess', function (event, toState) {
if (toState.name === 'myBaseStateName') {
$ionicHistory.clearHistory();
}
});
now it depends if you do not enabled view-caching you can put:
$ionicHistory.clearHistory(); directly in your startpage controller
if you have caching enabled you can listen on ionic view events in your startpage controller.
$rootScope.$on('$ionicView.enter', function () {
$ionicHistory.clearHistory();
});