Refreshing scopes when using view caching

I am using the default view caching and have noticed that since the controllers are not destroyed and recreated every time you navigate to a page, the scope variables never update.

How can I get functionality where I am caching the page but every time it loads the data is updated and therefore so is the view.

I tried wrapping my whole controller in:

$scope.$on('$ionicView.enter', function () { //my controller here });

and when debugging I can see that all the $scope variables are recreated/updated as expected but the data is not updating in the view

Have I missed something or are there any other ways to actually achieve this?

If the app/controller needs to know when a view has entered or has left, then view events emitted from the ionView scope, such as $ionicView.enter, may be useful

.controller('MainCtrl', function($scope){

 $scope.$on('$ionicView.enter', function(){

$timeout(function () {
  // change binding to scope values here
  $state.go('.', {}, { reload: true });
  }, 100);
1 Like

This worked for you?


$scope.$on(’$ionicView.enter’, function() is working fine.
Let me try your reload function

the reload function is not working.