【问题标题】:Meteor Angular, resolver $state.go not a functionMeteor Angular,解析器 $state.go 不是函数
【发布时间】:2015-11-24 09:03:57
【问题描述】:

所以,我有这个处理路由错误的函数:

angular.module('player-tracker').run(['$rootScope', '$location', function($rootScope, $state) {
    $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, rejection) {
      if (rejection === 'AUTH_REQUIRED') {
        $state.go("/home");
      }

   });
}]);

不是很复杂,我知道。

但是每当我运行它时,我都会遇到 $state.go 方法返回未定义的问题。我错过了什么吗?

【问题讨论】:

    标签: angularjs meteor angular-meteor


    【解决方案1】:

    如果要显式注入 $state,则必须将它包含在数组和函数的参数中,而不仅仅是后者。

    angular.module('player-tracker').run(['$rootScope', '$state', function($rootScope, $state) {
        $rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, rejection) {
          if (rejection === 'AUTH_REQUIRED') {
            $state.go("/home");
          }
    
       });
    }]);
    

    【讨论】:

    • 我试过了,还是说 $state.go 不是函数。
    • 编辑:正在运行的节点服务器正在运行....并且它有效。多么奇怪。
    猜你喜欢
    • 2015-06-15
    • 2023-03-12
    • 2021-07-13
    • 2018-04-07
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    相关资源
    最近更新 更多