Hello,
I’m facing an issue : I’m using the ionic tabs class. I have various tabs such as customers, contacts, etc.
Each tab contains only an ion-nav-view which name is different for each tab. However, in my contacts tab, I’ve a list of contacts. On click on one item on this list, I want to show the detailed contact. To do this, I have two states, which urls are /contacts for the list of contacts and /contacts/:id for one specific contact.
Both states are loaded in the same view, contained in the tab concerning the contacts. I don’t know if I’m really clear.
So, it works fine, when I click on my contacts tab, I’ve the list of my contacts. And when I click on one of these contacts, I can see it more precisely. And the back button in my header bar is working well.
However, my problem is that the link (meaning when I click on my contacts tab) is replaced : it is to say, when I click first on my contacts list, I see my list of contacts. Then, if I click on one contact, I see the contact. BUT, if from this last view, I click on an another tab such as customers, and I came back to my contacts tab. I see the last view, meaning one contact precisely, instead of all my contacts. It seems that the link behind the nav tabs is replaced, from /contacts to /contacts/0 for example. And i don’t understand why.
[update] : Got one hack. Instead of placing a href on my ion-tab (something like <ion-tab class="...." href="/xxx/yyy/zzz">), I’ve replaced href by ng-click="myFunction()". The function “myFunction()” load the good state via $state.go("mystate"). (don’t forget to inject $state in the controller parameters). If you have a better idea, tell me.
I think it’s because you don’t go to a child. You go from /tab/dash to /tab/friend/2. That’s why it works fine when you go from /tab/friends to /tab/friends/2 and not from dashboard to friends. Because dashboard and friends are tabs. There isn’t back button when your nav is between tabs.
I don’t really know if it’s a bug. If I try on my app it works the same way, I tested it via URL and yes it does not provide back button, because I never went through the parent. May be you should add a layer to get the good parent.
I’ll check this when I go back home. Wait 4 hours please.
[edit] : Ok so here is a working solution : http://plnkr.co/edit/xjMZ2FVoel2SO81Dn9Ix?p=preview
However it’s quite ugly. The clue is to go through the tab.friends state before tab.friends-detail state, because it is the way angular handles it.