Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$state.go() doesn't load controller in ionic application

Using the following code, when a page with id=0 loads first time there is no problem with controller. But when again the same page loads with same id=0 again, it does not loads controller.

$state.go('tab.dash', {
  id: $rootScope.products[CONSTANTS.i].id
}, {
  reload: true
});

How does it happen? Please suggest me a solution.

like image 466
anoop m m Avatar asked Oct 20 '22 14:10

anoop m m


1 Answers

I encountered a similar problem where I needed stats to recalculate every time a tab was visited.

You need to disable view caching. You can do so in the route setup. For example:

.state('tab.stats', {
 url: '/stats',
 views: {
   'tab-stats': {
     templateUrl: 'templates/tab-stats.html',
     controller: 'StatsCtrl'
   }
 },
 cache: false
})
like image 79
Eric Himmelreich Avatar answered Oct 22 '22 02:10

Eric Himmelreich