在$ state.go之后没有调用离子控制器 [英] ionic controller not called after $state.go

查看:83
本文介绍了在$ 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 try to open it again it does not load the new data

这里是如何

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

这里是被调用的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'
      });
    });
})

推荐答案

我有类似的问题。第一次仅在重新加载后显示。原因是视图缓存。使用 缓存禁用 ,就像我的具体情况一样:

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

这篇关于在$ state.go之后没有调用离子控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆