登录后重定向

Redirection after login

我的应用程序存在重定向问题。这些是我的州提供者:

testApplication.config(function($stateProvider, $urlRouterProvider) {

$stateProvider

.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})

.state('app2', {
url: "/app2",
abstract: true,
templateUrl: "templates/menu2.html",
controller: 'AppCtrl'
})

.state('app2.login', {
url: "/login",
views: {
  'menuContent': {
    templateUrl: "templates/login.html",
    controller: 'LoginCtrl'
  }
}
})

.state('app.profile', {
url: "/profile",
views: {
  'profile' :{
      templateUrl: "templates/profile.html",
      controller: "ProfileCtrl"
  }
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app2/login');
});

我的 AppCtrl 是空的,这是我的 LoginCtrl:

testApplication.controller('LoginCtrl', function($scope, $location){ 
 $scope.fbLogin = function() { 
   openFB.login( function(response) { 
     if (response.status === 'connected') {
       // This runs on success 
        console.log('Facebook login succeeded');
        $scope.$apply( function () { $location.path('profile') } ); 
     } else { 
          alert('Facebook login failed'); 
     } 
   }, {scope: 'email,publish_actions,user_friends'}
  ); 
 }; 
})

问题是我在登录后没有被重定向。但是如果我改变

$urlRouterProvider.otherwise('/app2/login');

$urlRouterProvider.otherwise('/app/profile');

然后手动转到“#/app2/login”登录 我被重定向到个人资料页面。我该如何解决?

尝试

$state.go('app.profile') 

而不是

$scope.$apply( function () { $location.path('profile') } );

我希望这对其他人也有帮助。