ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: $ionicView.clearCache() breaks tabs with multiple views

Open bodinaren opened this issue 11 years ago • 4 comments

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?

bodinaren avatar Apr 07 '15 08:04 bodinaren

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

perrygovier avatar Apr 14 '15 20:04 perrygovier

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.

adamdbradley avatar Apr 15 '15 16:04 adamdbradley

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?

chris08002 avatar May 12 '15 12:05 chris08002

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.

siada avatar Feb 23 '16 15:02 siada