所以我有登录界面,我登录Facebook(这很完美),一旦FB登录成功,它应该转到另一个视图。我尝试用
实现这一目标$state.go("app.start")
但它不起作用。它只停留在登录视图上。不知道为什么我的$ state.go不起作用......
登录按钮的控制器:
angular.module('MovieBankUser.controllers',[])
.controller('LoginCtrl', function($scope, LoginService, $state) {
$scope.loggingIn = false;
$scope.login = function () {
if (!$scope.loggingIn) {
$scope.loggingIn = true;
LoginService.loginUser().then(function () {
$scope.loggingIn = false;
//$window.location.href = "#/app/start"
$state.go('app.start');
//console.log("TEST TEST");
});
}
}
});
我的部分app.js路由代码:
// Routes
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'views/login/login.html',
controller: 'LoginCtrl'
})
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'components/sidebar_menu/menu.html',
controller: 'AppCtrl'
})
.state('app.start', {
url: '/start',
views: {
'menuContent': {
templateUrl: 'views/start/start.html',
controller: 'MovieCtrl'
}
}
})
.state('app.trending', {
url: '/trending',
views: {
'menuContent': {
templateUrl: 'views/trending/trending.html',
controller: 'MovieCtrl'
}
}
})
.state('app.trending-detail', {
url: '/trending/:id',
views: {
'menuContent': {
templateUrl: 'views/trending/trending_detail.html',
controller: 'MovieDetailCtrl',
resolve: {
movie: function($stateParams, MovieService) {
return MovieService.getMovieById($stateParams.id)
},
trailer: function($stateParams, MovieService) {
return MovieService.getTrailerById($stateParams.id)
},
cast: function($stateParams, MovieService) {
return MovieService.getCastCrewInfo($stateParams.id)
}
}
}
}
})
.state('app.outnow', {
url: '/outnow',
views: {
'menuContent': {
templateUrl: 'views/out_now/outnow.html',
controller: 'MovieCtrl'
}
}
})
.state('app.outnow-detail', {
url: '/outnow/:id',
views: {
'menuContent': {
templateUrl: 'views/out_now/outnow_detail.html',
controller: 'MovieDetailCtrl',
resolve: {
movie: function($stateParams, MovieService) {
return MovieService.getMovieById($stateParams.id)
},
trailer: function($stateParams, MovieService) {
return MovieService.getTrailerById($stateParams.id)
},
cast: function($stateParams, MovieService) {
return MovieService.getCastCrewInfo($stateParams.id)
}
}
}
}
})
.state('app.comingsoon', {
url: '/comingsoon',
views: {
'menuContent': {
templateUrl: 'views/coming_soon/comingsoon.html',
controller: 'MovieCtrl'
}
}
})
.state('app.comingsoon-detail', {
url: '/comingsoon/:id',
views: {
'menuContent': {
templateUrl: 'views/coming_soon/comingsoon_detail.html',
controller: 'MovieDetailCtrl',
resolve: {
movie: function($stateParams, MovieService) {
return MovieService.getMovieById($stateParams.id)
},
trailer: function($stateParams, MovieService) {
return MovieService.getTrailerById($stateParams.id)
},
cast: function($stateParams, MovieService) {
return MovieService.getCastCrewInfo($stateParams.id)
}
}
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/login');
});