I have one template 'song-detail' that I want to access from two other parts of my application. However, I can only use the nav history for the first one.
I want to access 'song-detail' from both the browse nav view, and the favourites nav-view. I can access it fine from both, but I only get the 'back' history from the tabs.browse.
Is it possible to get the nav history when sharing a single 'song-detail' view like this?
.state('tabs', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tabs.browse', {
url: '/browse',
views: {
'tab-browse': {
templateUrl: 'templates/tab-browse.html',
controller: 'BrowseCtrl'
}
}
})
.state('tabs.song-detail', {
url: '/songs/:song_id',
views: {
'tab-browse': {
templateUrl: 'templates/song-detail.html',
controller: 'SongDetailCtrl'
}
}
})
.state('tabs.fav', {
url: '/fav',
views: {
'tab-fav': {
templateUrl: 'templates/tab-fav.html',
controller: 'FavCtrl'
}
}
})
.state('tabs.fav-detail', {
url: '/songs/:song_id',
views: {
'tab-fav': {
templateUrl: 'templates/song-detail.html',
controller: 'SongDetailCtrl'
}
}
})
I guess you have missed the abstract state:
.state('tab', {
url: "/tab",
abstract: true,
templateUrl: "templates/tabs.html"
})
then you'll have the tabs container (tabs.html):
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
<ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" href="#/tab/browse">
<ion-nav-view name="tab-browse"></ion-nav-view>
</ion-tab>
...
</ion-tabs>
You have to change your last state:
.state('tabs.fav-detail', {
url: '/fav/:song_id',
views: {
'tab-fav': {
templateUrl: 'templates/song-detail.html',
controller: 'SongDetailCtrl'
}
}
})
notice the url: url: '/fav/:song_id'
and this is your tab-fav.html:
Notice you have the link to href="#/tab/fav/{{song.id}}
.
Everything should work as expected.