bug: $ionicView.clearCache() breaks tabs with multiple views
Type: bug
Platform: all
I found a problem with $ionicView.clearCache(). I have a tab-based app in which I want to clear the view cache at certain times. Check this codepen:
Note that in tab 1 and tab 2 I have two views like so:
<ion-tab>
<div ui-view="tab1-top" /> //(shown in gray background)
<ion-nav-view name="tab1">
</ion-tab>
Now when you clear the cache by clicking any of the "Clear cache"-buttons, Tab 1 and Tab 2 (except the one you currently have active, if either) will stop working. However, Tab 3 which only has an ion-nav-view (no ui-view) works just fine.
I've narrowed down the problem to this commit (js/angular/directive/tab.js:181). Removing this line and everything seems to work just fine, but I suspect it re-introduce the initial problem the commit intended to fix?
wow, tabs with multiple views in a single state wasn't something we were planning on supporting. If you're saying it did work until recently though, we'll take a look. The codepen had some syntax errors in it. Here's a version that runs smoothly: http://codepen.io/perrygovier/pen/VYozmp
You're right in that removing that line will cause a regression in caching. The feature of having a ui-view sitting next to a ion-nav-view which is inside a tab is not one we'll support for the v1 release.
I have the same issue with this tab configuration:
<ion-tab title="Crear job" icon="icon ion-plus-round tab-light" href="#/tab/createjob">
<ion-nav-view name="tab-createjob"></ion-nav-view>
<div ng-show="isOffline==true" class="bar bar-subheader bar-assertive">
<h2 class="title">Offline: No tienes internet</h2>
</div>
</ion-tab>
The "div" causes that $ionicHistory.clearCache() destroys the views. Am I not allowed to do anything else than one "ion-nav-view" inside the "ion-tab"? Any other suggestions to make a header bar in the tabs to show "Offline" state?
You also encounter this issue if you set:
$ionicConfigProvider.views.maxCache(0);
On your app, you will end up with tabs that work once and when you go to re-visit them, they will no longer work.
Edit: I've created a basic Codepen that outlines the issue I encounter: http://codepen.io/anon/pen/xZvqRR
Open it up, click tab-2, you'll switch to tab 2, click back totab-1 and you'll get nothing.