Reinitialize Controller every time you visit View - Ionic Framework

Hi, I have two views in my application with two controllers assigned to each. Here I need to reinitialize the controller every time I switch to a specific 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 tried to implement many solutions on the stack, but none of them helped me. The solution worked 1 / The solution was tried 2

+1
source share
1 answer

If the question that the update is not updating disables the cache may help

i.e

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

By default, views are cached for better performance. You can also disable the cache via the "cache-view" attribute

 <ion-view cache-view="false" view-title="My Title!"> ... </ion-view> 
+4
source

All Articles