所有,
我有一个AngularJS PhoneGap的应用我的工作。我被困在接收到API调用响应后立即发生的一个重定向。我的代码位于gist.github.com
我的问题是在第300行的controllers.js,我打电话给我的重定向在一个then()块。
UserService.login($scope.user.email, $scope.user.password)
.then(function(response) {
globals.session_id = response.data.meta.session_id;
globals.logged_in_userId = response.data.response.users[0].id;
if ($scope.user.remember === true) {
window.localStorage.setItem("_session_id", response.data.meta.session_id);
window.localStorage.setItem("logged_in_userId", response.data.response.users[0].id);
} else {
window.localStorage.removeItem("_session_id");
window.localStorage.removeItem("logged_in_userId");
}
})
.then(function() {
$location.path("/tab/locations");// <=== This line doesn't cause an error but does not result in a redirect
})
.
catch (function(response) {
alert(JSON.stringify(response));
});
如果有人可以请帮助我,我会很感激!
感谢, 布鲁斯
使用rootScope到目前为止,我已经试过申请,适用范围,并使用与范围的手表沿承诺回报中的变量,并且在任何时候做重定向工作。我也尝试使用window.navigation.href,我什么都没有。 必须有成功登录后重定向用户的方法。 – jaxmeier