2
我到处寻找,但没有任何潜在的解决方案已经工作。
登录页面应该在成功登录或注册后路由到标签页面。由于某种原因,它每次都会回到根目录或otherwise
状态。有没有人有什么建议?谢谢!
国:
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('intro', {
url: '/intro',
templateUrl: 'templates/intro.html',
controller: 'IntroCtrl'
})
.state('signin', {
url: '/sign-in',
templateUrl: 'templates/sign-in.html',
controller: 'SignInCtrl'
})
.state('forgotpassword', {
url: '/forgot-password',
templateUrl: 'templates/forgot-password.html'
})
.state('tabs', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.state('tabs.home', {
url: '/home',
views: {
'home-tab': {
templateUrl: 'templates/home.html',
controller: 'HomeTabCtrl'
}
}
});
$urlRouterProvider.otherwise('/intro');
})
控制器应该在登录路由的标签页:
.controller('SignInCtrl', function($scope, $state, $firebaseAuth, $location) {
$scope.login = function(username, password) {
var fbAuth = $firebaseAuth(fb);
fbAuth.$authWithPassword({
email: username,
password: password
}).then(function(authData) {
$location.path('/tab')
}).catch(function(error) {
console.error("ERROR: " + error);
});
}
$scope.register = function(username, password) {
var fbAuth = $firebaseAuth(fb);
fbAuth.$createUser({email: username, password: password}).then(function() {
return fbAuth.$authWithPassword({
email: username,
password: password
});
}).then(function(authData) {
$location.path("/tab");
}).catch(function(error) {
console.error("ERROR " + error);
});
}
})
您是否尝试过使用'$ state.go( '标签' )而不是'$ location'服务? –