我正在尝试在身份验证后更改页面,但除非我再次单击登录按钮,否则没有任何反应。
以下是代码:
myApp.controller('AuthController', ['$scope','$location', function($scope,$location) {
// (1) $location.path('/produtos');
$scope.email = '';
$scope.pass = '';
$scope.submit = function() {
var ref = new Firebase("https://myfirebasedb.firebaseio.com/");
ref.authWithPassword({
email : $scope.email,
password : $scope.pass
}, function(error, authData) {
if (error) {
console.log("Login failed !", error);
} else {
console.log("Login ok ! "); // (2)
$location.path('/produtos');
}
});
};
}]);
以下是观察结果 -
提前谢谢。
答案 0 :(得分:0)
看起来有些东西会中断位置变化。试试setTimeout(function(){$location.path('/produtos');}, 0);
- 在这种情况下有所帮助。