AngularJS $state.go 没有重定向到其他页面

AngularJS $state.go is not redirecting to other page

下面是我的控制器代码,

app.controller('logoutCtrl', ['$scope', '$http','$window','$state',
  function ($scope, $http,$window,$state) {

        $scope.logout = function() {
          console.log('inside logmeout');
          delete $window.sessionStorage.token;
          $state.go('access.login');
        };

  }]);

HTML

<li class="last" ng-controller="logoutCtrl">
    <a href="" ng-click="logout()">
         <i class="material-icons">lock</i> Logout
    </a>
</li>

app.router.js

            .state('access', {
                url: '/access',
                template: '<div ui-view class=""></div>'
            })
            .state('access.login', {
                url: '/login',
                templateUrl: 'partials/ui-login.html',
                controller: 'LoginFormController',
                resolve: {
                    deps: ['uiLoad',
                        function(uiLoad) {
                            return uiLoad.load(['scripts/controllers/login.js',
                                '../bower_components/font-awesome/css/font-awesome.css']);
                        }
                    ]
                }
            })

单击注销时我无法重定向到另一个状态 ('access.login')。 控件进入 logout() 并且能够打印控制台消息并且正在删除令牌但重定向没有发生.. 我能得到任何帮助吗..

在您的模块定义中,您需要将 'ui.router' 作为依赖项传递,以便在您的项目中使用 Angular-UI-路由器:

例如angular.module('my_app', ['ionic', 'ui.router'])

它也适用于我。

$state.go('the-state-name-in-quotes')

如果您的网页显示在视图中,请不要忘记在要显示网页的父页面中包含 ui-view。

<div ui-view>
  <!-- Child page will appear here -->
</div>