I’m getting started here with ionic and have an alert()
within a controller. The first time I access the controller, it fires, however subsequent attempts it doesn’t load, seems like once the view is there it’s cached. I’m using the basic setup from the getting started, so just created a new controller.
Ionic now caches views and their controllers to increase in app functioning speed. Otherwise, it does what you’re intending it to do, but the entire controller. Option one is to turn off caching completely (I recommend against that as it makes for weird transitions) or you can use the events that are awesome because you can then control a lot more of what’s happening with the controller.
$scope.$on(’$ionicView.beforeEnter’, function() {
// Your logic here
});
http://ionicframework.com/docs/api/directive/ionNavView/
there is information on the caching and
http://ionicframework.com/docs/api/directive/ionView/
the details and list of events that the view fires
Cheers!