Bust controller cache only when navigating from side menu

I’m looking for a way to bust the view cache only when navigating from the side menu.

I can’t use cache-view="false" in the template because that will totally disable caching (i.e. the controller will reload even when going “back” from deeper in the navigation stack).

I can’t disable caching globally, again for the same reason as above.

I can’t use ui-sref-opts="{reload:true}" because Ionic seems to ignore that and perform its own caching anyway.

I can’t seem to use $ionicView.enter or $ionicView.beforeEnter view lifecycle events because those are triggered even when you navigate back to the view.

My use case is that one of my side-menu navigation items is a calendar. I want it to always reset to “today” when you tap on the side menu entry, but you may have navigated to a different month then drilled down further. When you go back, it should stay on the month you selected. It should only reset when navigating from the side menu.

Unfortunately I have not been able to discover a way to detect this scenario.

Thanks for your help!
Luke

Could you include a parameter within state that can be passed inside the link that will reset the state back to original? This isn’t a cache invalidation per se, just your own code setting up things as needed. You can do that inside $ionicView.beforeEnter event handler.

That would be great, but I still can’t figure out how to detect the difference between $ionicView.beforeEnter getting triggered from a “back” action, and when a side-menu option is chosen.

The state is identical in both cases.

For posterity, I figured out a hack around this problem.

    $scope.$on('$ionicView.beforeEnter', function() {
      if (!$ionicHistory.viewHistory().forwardView) {
        reload();
      }
    });