简体   繁体   English

$state.go 后未调用 Ionic 控制器

[英]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:这是称为balanceInquery状态控制器:

.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'
      });
    });
})

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:使用cache: false禁用它,就像在我的特定情况下一样:

$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
  })

This is due to view caching, which can be disabled in a variety of ways.这是由于视图缓存,可以通过多种方式禁用它。 See http://ionicframework.com/docs/nightly/api/directive/ionNavView/ for more details.有关更多详细信息,请参阅http://ionicframework.com/docs/nightly/api/directive/ionNavView/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM