angularjs-uirouter $state.go 错误为 .go undefined

angularjs-uirouter $state.go Error as .go undefined

这里正在 $statechangStart 中获取错误 我正在尝试检查我在 $statechageStart

中的凭据
.config(function ($stateProvider, $urlRouterProvider) {
        $stateProvider
         .state('Login',{
                url:'/LoginService',
                templateUrl: '/ApiClient/Home/LoginPage.html',
                controller:'LoginController'

            })
  $urlRouterProvider.otherwise('/')
    })

     .run(function ($rootScope) {
            $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams, options, $scope, $state) {
                debugger;
                if (toState.module == "Private" && sessionStorage.getItem('employee')!=null) {}

                else {
                    event.preventDefault();
                     $state.go('Login');
                }

你需要注入 $state 到你的 .运行 ,否则它是未定义的

.run(function ($rootScope, $state) 

编辑

在 $stateChangeStart 事件中使用 $state.go 是一种不好的做法。为了您的目的,您最好在设置超时后应用 state.go

   $timeout($state.go.bind(null, 'Login'), 3000);