myApp.controller('RegistrationController', ['$scope',
function($scope) {
var auth = firebase.database().ref();
// console.log("auth::"+auth);
$scope.login = function() {
$scope.message = "Welcome " + $scope.user.email;
}; //login
$scope.register = function() {
console.log($scope.user.email);
console.log($scope.user.password);
console.log("jdxnx::" + auth);
firebase.auth().createUserWithEmailAndPassword($scope.user.email, $scope.user.password).then(function() {
$scope.message = "Hi" + $scope.user.email + " you have registered"
}).catch(function(error) {
$scope.message = error.message;
console.log($scope.message);
}); // //createUser
}; // register
}
]); // Controller
When I submit my registration details, the register function is triggered. However, the issue arises where the event exits the
firebase.auth().createUserWithEmailAndPassword
before receiving a response, resulting in the {{message}}
value remaining blank on the HTML page. This happens because the event returns to the page before the process completes. I would like the event to wait until a response is received from firebase.auth().createUserWithEmailAndPassword($scope.user.email,$scope.user.password)
.
Please note that I am working with Firebase version 3.x.x.