location.path不会重定向到新位置?

时间:2014-05-30 12:39:59

标签: angularjs authentication angularjs-routing

我正试着从角度js的登录页面重定向。在我的路线中,我有2个安全链接和一个公共链接:

app.config(['$routeProvider', function ($routeProvider) {
    $routeProvider
        .when('/customers', {
            controller: 'CustomersController',
            templateUrl: 'customers.html',
            secure: true
        })
        .when('/login/:redirect*?', {
            controller: 'LoginController',
            templateUrl: 'login.html'
        })
        .when('/testing', { templateUrl: 'testing.html' })
        .otherwise({ redirectTo: '/login' });

}]);

当我点击客户链接并使用电子邮件“admin@mail.com”登录并且密码无关紧要时,不会显示customer.html模板的位置:

  if ($scope.email != "admin@mail.com") {
    $scope.errorMessage = 'Unable to login';
    return;
  }

  if ($scope.email == "admin@mail.com" && $routeParams && $routeParams.redirect) {
    path = path + $routeParams.redirect;
  }

  $location.path();

plunkr:http://plnkr.co/edit/nvp3eoDn1bv6XNCqzfQx?p=preview

0 个答案:

没有答案