![](/img/trans.png)
[英]firebase and auth property does not exist in Ionic and Firebase
[英]Ionic/Firebase Success function after Auth
我有此登錄功能,正在運行。 但是我只在沒有發現錯誤的情況下才嘗試重定向。 我在下面嘗試了這段代碼,但這不能按我想要的方式工作,任何想法,例如我不知道的成功函數?
$scope.loginEmail = function($email, $password){ var testing = 1; $scope.error = ''; firebase.auth().signInWithEmailAndPassword($email, $password).catch(function(error) { var errorCode = error.code; var errorMessage = error.message; $scope.error = errorMessage; testing = 0; console.log("Testing 1 : ", testing); }); if(testing === 1) { console.log("Testing 2 : ", testing); $state.go("menu.VNements"); } };
該函數返回一個Promise - catch
表示錯誤, then
表示成功。
function signInSuccess(response) {
console.log('signInSuccess', response);
}
function signInError(response) {
console.log('signInError', response);
}
firebase.auth().signInWithEmailAndPassword($email, $password)
.then(signInSuccess);
.catch(signInError);
為了更加清晰,我將代碼放在這里,通過Dominic Tobias,它可以正常工作!
$scope.loginEmail = function($email, $password){ function signInSuccess(response) { console.log('signInSuccess : ', response); $state.go("menu.VNements"); } function signInError(response) { console.log('signInError : ', response); } firebase.auth().signInWithEmailAndPassword($email, $password) .then(signInSuccess) .catch(signInError);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.