My Controller is not calling each time

.controller(‘EventCtrl’, function($scope, $rootScope, $location) {

$scope.initfun=function(){
  console.log("TEST");
};

$scope.initfun();

})

suppose there is a page named index.html#/event
when it is called first time “TEST” is displayed in console
but when it is called second time it is not working.

Thank you.

View-Caching caches the scope and template the first time you navigate to the view.
If you reenter the view -> the cached one is used.

to re-call your function to not cache that view or listen to ion-view events:
http://ionicframework.com/docs/api/directive/ionView/

like $ionicView.enter to run your code everytime you enter the view :wink:

2 Likes

Thanks Man…
and what should i use instead of $window.history.back(); because it’s not working currently.
i’ve done some project with old versions of ionicframework in which thoes $window… kind of functions were working. but in latest version of ionicframework it’s not working.

http://ionicframework.com/docs/api/service/$ionicHistory/

:wink:

$ionicHistory.goBack()

1 Like