My app has four views: a splash page (no tabs), login, home, and filters (all with tabs that route to the three of them). When I navigate through the tabs, say splash -> home -> filters -> home -> login -> home when I use the back button in the browser (or android's system back) it'll go all the way from home -> login -> home -> filters -> home -> splash. I'd like it treat the home page as a home page with no history attached to it. When navigating back after splash -> home -> filters -> home -> login it should be login -> home and that's the end of it.
Here's my .config():
.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
// Android
$ionicConfigProvider.tabs.position('bottom');
// States
$stateProvider
.state('tab',{
url:'/tab',
abstract: true,
templateUrl: 'templates/tabs.html',
controller:'TabCtrl'
})
.state('splash',{
url:'/',
templateUrl:'templates/splash.html',
controller:'SplashCtrl',
onEnter: function($state){
// $state.go('tab.home');
}
})
.state('tab.login',{
url:'/login',
views:{
'tab-login':{
templateUrl:'templates/login.html',
controller:'LoginCtrl'
}
}
})
.state('tab.home',{
url:'/home',
views:{
'tab-home':{
templateUrl:'templates/home.html',
controller:'HomeCtrl'
}
}
})
.state('tab.filters',{
url:'/filters',
views:{
'tab-filters':{
templateUrl:'templates/filters.html',
controller:'FiltersCtrl'
}
}
})
$urlRouterProvider.otherwise('/');
})
I'm using ui-srefs for the tab navigation and here's that:
<ion-tabs class="tabs-icon-only tabs-color-active-positive">
<!-- Login Tab -->
<ion-tab title="Login" icon-off="ion-person" icon-on="ion-person" ui-sref="tab.login" >
<ion-nav-view name="tab-login"></ion-nav-view>
</ion-tab>
<!-- Home Tab -->
<ion-tab title="Recipes" icon-off="ion-home" icon-on="ion-home" ui-sref="tab.home" on-select="enteringHome()" on-deselect="">
<ion-nav-view name="tab-home"></ion-nav-view>
</ion-tab>
<!-- Filters Tab -->
<ion-tab title="Filters" icon-off="ion-search" icon-on="ion-search" ui-sref="tab.filters" >
<ion-nav-view name="tab-filters"></ion-nav-view>
</ion-tab>
</ion-tabs>