使用ui-route重定向路由似乎不需要

时间:2015-07-19 19:34:59

标签: angularjs angular-ui-router

好的,所以我用Yeoman创建了一个项目(angular-fullstack - > ui-route),并且能够将主视图直接更改为登录视图。现在,当您成功登录时,它应该重定向到我选择的所需路线。

我的文件夹结构如下所示 - > http://gyazo.com/a5e60dc2bc873c769f5926353829881c

我正在尝试重定向到month.html视图。这是此代码(login.controller.js)

'use strict';

angular.module('zazzleToolPlannerApp')
  .controller('LoginCtrl', function ($scope, Auth, $location) {
    $scope.user = {};
    $scope.errors = {};

    $scope.login = function(form) {
      $scope.submitted = true;

      if(form.$valid) {
        Auth.login({
          email: $scope.user.email,
          password: $scope.user.password
        })
        .then( function() {
          // Logged in, redirect to home
          $location.path('/month');
        })
        .catch( function(err) {
          $scope.errors.other = err.message;
        });
      }
    };

  });

calendar.js代码:

'use strict';

angular.module('zazzleToolPlannerApp')
  .config(function ($stateProvider) {
    $stateProvider
      .state('day', {
        url: '/day',
        templateUrl: 'app/calendar/day/day.html',
        controller: 'CalendarCtrl',
        authenticate: true
      })
      .state('week', {
        url: '/week',
        templateUrl: 'app/calendar/week/week.html',
        controller: 'CalendarCtrl',
        authenticate: true
      })
      .state('month', {
        url: '/month',
        templateUrl: 'app/calendar/month/month.html',
        controller: 'CalendarCtrl',
        authenticate: true
      });
  });

但是当我登录时没有任何反应,虽然我的控制台显示登录成功 - > http://gyazo.com/ddd066e0f399027d3cffa266f647a8e0

0 个答案:

没有答案