sameera207
sameera207

Reputation: 16629

Loading controllers when navigating through screens

I'm 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 it's not happening

I'm not sure if this is the default behavior, or am I missing something?

Upvotes: 0

Views: 31

Answers (1)

Dayan Moreno Leon
Dayan Moreno Leon

Reputation: 5435

if you are using nested states, parent.child1, parent.child2, parent only loads 1 for the entire hierarchy, changing from child1 to child 2 will not reload the parent controller, thats one of the pros of using ui-router.

also note that with ionic latest version they introduced view caching so, the controller is only instanciated once for each view, to prevent that you need to use

cache-view="false" 

in your ion-view

http://ionicframework.com/docs/api/directive/ionNavView/

Upvotes: 1

Related Questions