javascript - AngularFire (Angular + Firebase) Authentication Error delay -
i found out weird. please help!
$scope.login = function() { ref.authwithpassword({ email: $scope.user.email, password: $scope.user.password }, function(error, authdata) { if (error) { console.log("login failed!", error); $scope.message = error.tostring(); } else { $location.path('/meetings'); console.log("authenticated payload:", authdata); } }); } //login this login function , works nicely.however, thing error 3, 4 sec after have submitted login. noticed {{message}} not being updated after receive value @ $scope.message . thought angular should show value changes. ?
after click second time, error showed.
this printing value:
<p class="error formerror" ng-show="message">{{message}}</p>
you're calling authwithpassword, part of firebase's regular javascript sdk. api start authentication process , call function when authentication completes. unfortunately @ point angularjs no longer aware of updates make $scope.
to make angularjs aware of update, wrap code in $timeout call:
$scope.login = function() { ref.authwithpassword({ email: $scope.user.email, password: $scope.user.password }, function(error, authdata) { $timeout(function() { if (error) { console.log("login failed!", error); $scope.message = error.tostring(); } else { $location.path('/meetings'); console.log("authenticated payload:", authdata); } }); }); } //login note precisely reason, angularfire provides convenience wrappers around these authentication functions in $firebaseauth service. see section in angularfire guide on logging users in.
the wrapper function you're looking $authwithpassword, read sample of how use $authwithpassword in api documentation.
Comments
Post a Comment