[SOLVED] Loading controllers when navigating through screens

Hi All

Im currently using directives in my ionic app, there directives are normally bind to a angular controller.
So my problem is, when I navigate through the app, my controllers are not loading (loads for the first time) and hence I cannot setup some initial values.

Following is an example

  1. I navigate to users screen/page
  2. users controller loads (When I check with chrome dev tools)
  3. I navigate to home screen
  4. I navigate back to users screen

** At this point I expect users controller to load again, to setup my initial values. but its not happening

I’m not sure if this is the default behavior or am I missing something.

I hope I put the question clear, thanks in advance




AngularJs controllers are singletons, they persist their values between view loads. You’ll need to check out the events that are available for ion-views.


you can run the event like below…

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

I think what you want is either enter or afterEnter

Hey @dalefrancis88, thanks for the answer, I was able to fix it by using cache-view="false", but I think u r solution is better as it will allow to clear cache programatically (if only a change happend…) thanks again