I have a function in my ionic app to check if user email is already exists in firebase database.
checkValidEmail(email):any{
let result=this.userService.getUserByEmail(email);
console.log(result);
result.subscribe((k:User[])=>{
if(k.length>0){
return true;
}else{
return false;
}
});
}
I am trying to pass its boolen result in following if condition to check whether entered email address is already exists in database. It it exists display an error.
if(this.checkValidEmail(this.user.email)){
console.log("Error : Already has this email address ");
this.error ="Already has this email address in out system";
}
But I cant get true
or false
into if(this.checkValidEmail(this.user.email))
. Please help I'm new in this.