Problem with tabs in detail view


#1

Hi,

I’ve got some troubles using tabs in a detail view.
Full demo in Playground : http://play.ionic.io/app/ecc5b2ab51a0

Here is my usecase I need :
- show a list of items
- when you click on an item, you go to a details view containing tabs
- tabs in detail view should have informations relative to the clicked item

My problem is : the second tab (in fact, all except the first one) keep informations about the first visited item and do not update. Looking at urls (in my app) it’s really clear.

I think this problem is caused by tabs history management but I don’t know how to fix it…

So my questions :

  1. Do I have made a mistake ?
  2. Do you have an idea on how to solve this ? (real solution or ugly hack…)
  3. Do you know an other UI pattern to display a lot of informations in a detail view ? (not using tabs…)

Thanks


#2

Your problem is that the view is being “cached” (see the Caching section in http://ionicframework.com/docs/api/directive/ionNavView/)

I’ve switched off caching (see cache: false in the routes) and I believe it works as you wanted: http://play.ionic.io/app/0bc2b8f0ca96

The best thing to do however is don’t assume code in the body of your controller will be called every time the view is rendered, instead listen to one of the events (see link) perform the controller initialisation in response to one of them.


#3

Thanks a lot, it works as expected :smile:

I probably miss something about the cache…

Routes like /list are cached and controller’s code is executed once
Routes like /details/:id are cached depending on the id, so one controller is loaded for each id
Here, I have a route like /details/:id/tab1, I thought it were like for /details/:id but it’s more like /list

Do you have any explanation ?


#4

In fact, the cache could be desactived only on the tab view (/details/:id) and it’s working correctly : http://play.ionic.io/app/4c1d409d3a7e

I think there is something not clear in Ionic caching, maybe a bug… But it’s working now :slight_smile: