1

Hi i'm having two views in my app with two controllers assigned to each. Here i need to reinitialize the controller every time when ever i navigate to particular view.

Angular Script:

.state('app.pnrlist', {
            url: "/pnrlist",
            views: {
                'menuContent': {
                    templateUrl: "templates/test.html",
                    controller: "testControl",
                    reload: true
                }
            },
            reload:true
        })

        .state('app.home', {
            url: "/home",
            views: {
                'menuContent': {
                    templateUrl: "templates/home.html",
                    controller:"homeControl",
                    reload:true
                }
            },
            reload:true
        })

HTML Content

<ion-content>
  <ion-list>
    <ion-item nav-clear menu-close href="#/app/home">
      Home
    </ion-item>
      <ion-item nav-clear menu-close href="#/app/pnrlist">
          PNR List
      </ion-item>
  </ion-list>
</ion-content>

I have tried to implement many solutions on stack but none helped me. Solution Tried 1 / Solution Tried 2

Community
  • 1
  • 1
RameshKumar
  • 164
  • 1
  • 16

1 Answers1

4

If its a matter of the View not updating, disabling the Cache may help

i.e

.state('app.home', {
   url: "/home",
   cache: false,

As by default, views are cached to improve performance. You can also disable the cache via the 'cache-view' attribute

<ion-view cache-view="false" view-title="My Title!">
  ...
</ion-view>
sjm
  • 5,378
  • 1
  • 26
  • 37