3
我在我的应用程序中有一个重定向问题。这些是我的状态提供商:登录后重定向
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');
而且去手动“#/ APP 2 /登录”登录我重定向到的个人资料页面。我该如何解决这个问题?