How can we reload and re initilaize our controller to get the updated content


#1

how can we reload and re initilaize our controller on $state changes

What i have treid

//1
app.run(function($ionicPlatform, $rootScope, $ionicHistory) {
    $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
         $ionicHistory.clearCache();
    });
//2
$state.go('edit', {}, {reload: true});

#2

Depending on what you want to achieve, there can be better ways like using ionicView events in your controller:

$scope.$on( "$ionicView.enter", function() {
         // do stuff
    });

#3

i have two views one for edit and other is list on item click it goes to edit the item but when it came back items are not reloads i am using php as mysql for data


#4

then ionicview events should be enough


#5

it is not working i had tried


#6

Then you got it wrong, post your controller and service.


#7

i false the cache value in $stateProvider and it works for me :slight_smile:


#8

Yes but it has performance penalty, that’s why I did propose you a better alternative.