Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic controller not called after $state.go

I have a controller the get data from my back-end application when opening the state for the first time from the first controller it loads the data, but when it tries to open it again it does not load the new data

Here is how:

if (selectedServiceID == "000")
{
  $state.go('balanceInquery'); 
};

Here is the called balanceInquery state controller:

.controller('BalanceInqueryController', function($scope, getAccountBalanceService, $state, $ionicLoading, $ionicPopup) {
  getAccountBalanceService.get(username, pass, customerID, serviceAccID, langID)
    .success(function(data) {
      $scope.custBalance = data;
    })
    .error(function(data) {
      var alertPopup = $ionicPopup.alert({
        title: 'Error!',
        template: 'Sorry something went wrong'
      });
    });
})
like image 986
mohdcafory Avatar asked Mar 22 '15 11:03

mohdcafory


1 Answers

I had a similar problem. The first time was shown only after reload. The reason is view caching. Disable it with cache: false, like in my specific case:

$stateProvider
  .state('login', {
    url: '/login',
    controller: 'LoginCtrl as vm',
    templateUrl: 'app/login/login.html'
  })
  .state('tab', {
    url: '/tab',
    abstract: true,
    templateUrl: 'templates/tabs.html',
    cache: false
  })
like image 195
Carlos Morales Avatar answered Oct 15 '22 04:10

Carlos Morales