Removing cache of a view

Hi everyone,
After I remove the cache of a view using the attr cache-view="false" the console starts to show an error:
TypeError: Cannot read property 'backButtonTextLeft' of null

This happens when I add false to cache-view, then navigate to another view and click on back button, to come back to the view that I put the cache attr as false.

Why this is happening? @max Is that a bug?

We’re also experiencing this issue. See TypeError below.

TypeError: Cannot read property 'backButtonTextLeft' of null
    at leave (ionic.bundle.js:43279)
    at (ionic.bundle.js:43288)
    at IonicModule.controller.self.transition (ionic.bundle.js:46933)
    at IonicModule.controller.self.update (ionic.bundle.js:46906)
    at IonicModule.controller.self.beforeEnter (ionic.bundle.js:47240)
    at IonicModule.controller.self.beforeEnter (ionic.bundle.js:48219)
    at Scope.$get.Scope.$emit (ionic.bundle.js:22423)
    at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.emit (ionic.bundle.js:45968)
    at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.transition (ionic.bundle.js:45893)
    at ionic.bundle.js:47229ionic.bundle.js:19387 (anonymous function)ionic.bundle.js:16350 $getionic.bundle.js:22425 $get.Scope.$emitionic.bundle.js:45968 IonicModule.factory.ionicViewSwitcher.create.switcher.emitionic.bundle.js:45893 IonicModule.factory.ionicViewSwitcher.create.switcher.transitionionic.bundle.js:47229 (anonymous function)ionic.bundle.js:45785 (anonymous function)ionic.bundle.js:45874 IonicModule.factory.ionicViewSwitcher.create.switcher.renderionic.bundle.js:45784 IonicModule.factory.ionicViewSwitcher.create.switcher.initionic.bundle.js:47225 IonicModule.controller.self.renderionic.bundle.js:47181 IonicModule.controller.self.registerionic.bundle.js:50834 updateViewionic.bundle.js:50811 (anonymous function)ionic.bundle.js:22496 $get.Scope.$broadcastionic.bundle.js:39883 $state.transitionTo.$state.transition.resolved.then.$state.transitionionic.bundle.js:20962 processQueueionic.bundle.js:20978 (anonymous function)ionic.bundle.js:22178 $get.Scope.$evalionic.bundle.js:21994 $get.Scope.$digestVM7657:853 ng.config.$provide.decorator.$delegate.__proto__.$digestionic.bundle.js:19186 (anonymous function)ionic.bundle.js:12923 (anonymous function)ionic.bundle.js:8147 forEachionic.bundle.js:12922 fireUrlChangeionic.bundle.js:12898 cacheStateAndFireUrlChangeionic.bundle.js:10823 eventHandler

@Tijhaart yes, it’s the exactly same error. Did you remove the cache of a view using the attr of the directive too?

Yes I did.

I assumed removing the attribute completely would not trigger the error but the error remains. Also I use the html below to call goBack on tap which uses $state.go to navigate to a specific state.

<ion-nav-back-button class="button-clear ion-chevron-left" ng-click="noop()" on-tap="goBack()"></ion-nav-back-button>

I just use the nav-back-button without any function call, just let the ionic do manage the history behavior by itself. That’s weird…I will open an issue on github repo

So I guess for now nobody found the issue, correct?

I am in the same situation here!

I also have “$ionicConfigProvider.views.maxCache(0);”. Putting it to 1 or more “fix” the issue

Keep us posted if you have something to correct that!

Ok, I will tell you. If I find the code to fix I will open a PR

1 Like

Did see the same error and solved it with this:

$ionicHistory.nextViewOptions({disableBack: true});

before navigating to next view


Looks like it has to do with cache in router. If the view im going to from clicking back has cache false then the error occurs.

Somebody found a solution?

Something news about this issue ?

function enter(ctrlA, ctrlB, step) {
if (!ctrlA || !ctrlB) return;
var titleX = (ctrlA.titleTextX() + ctrlA.titleWidth()) * (1 - step);
var backTextX = (ctrlB && (ctrlB.titleTextX() - ctrlA.backButtonTextLeft()) * (1 - step)) || 0;
setStyles(ctrlA, step, titleX, backTextX);

function leave(ctrlA, ctrlB, step) {
  if (!ctrlA || !ctrlB) return;
  var titleX = (-(ctrlA.titleTextX() - ctrlB.backButtonTextLeft()) - (ctrlA.titleLeftRight())) * step;
  setStyles(ctrlA, 1 - step, titleX, 0);

this remove the error message but i dont no whats does the method does or not but ctrlB is also not available

I too am experiencing this issue, although I don’t believe I have disabled the cache of a view. It doesn’t seem like this problem though is causing any real issues, at least in browser testing seems to be working normally.

Better to add "cache: true" in app.js

.state("samplepage", {
        Url: "/samplepage.html",
        cache: true, **//it solve my problem**
        params: {
            sampleId: null
        views: {
            "menuContent": {
                templateUrl: "app/samplepage.html",
                controller: "samplepageCtrl"