Refreshing scopes when using view caching


#1

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?


#3

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


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

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

  });
});

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

#6

This worked for you?


#7

YES

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


#8

the reload function is not working.