When you create the basic Tabs project in ionic, you get tabs, "Status", "Chats", "Friends", "Account", and "Badges". Now, if I want to add a link on the Dashboard-Status view that routes me to a sub nav under the Friends tab, I can do that using the following:
<a ui-sref='tab.friend-detail'>
However, if I do that, I lose the back arrow that I would normally get if I navigate to the same view using the Friends tab. The work-around I use is to create a sub nav for "Home" that uses the same controller and view. Like this:
.state('tab.home-friend-detail', {
url: 'home/friend/:friendId',
views: {
'tab-friends': {
templateUrl: 'templates/friend-detail.html',
controller: 'FriendDetailCtrl'
}
}
})
and point to that state in the link. Is there a way to get to a sub-nav state from any view and maintain the back button/arrow that gets me back to the parent state? If this doesn't make sense, let me know and I'll try to clarify.
I don't think it's possible to keep the back button when you go directly to a nested-view state since the tabs keep their own stack of history seperately.
You could however go back to the parent state for any view by using $ionicHistory
and call $ionicHistory.goBack();
in your controller. This means however that you will have to create a custom back-button in your friend-detail page.