Hello ,
Please share some knowledge on “How can we validate email with dynamic data coming from firebase?”
Here is my code I stuck with this…
import { FormControl } from '@angular/forms';
import { UserProvider } from '../providers/database/user/user';
export class EmailValidator {
public users: any;
public email: any;
constructor(
public _DBUSER: UserProvider
) {
this.loadAndParseUsers();
}
loadAndParseUsers() {
this.users = this._DBUSER.renderAllUsers();
var allEmails = [];
this.users.forEach(element => {
console.log(element);
element.forEach(user => {
allEmails.push(user.email);
});
});
console.log(allEmails);
}
static checkEmail(control: FormControl): any {
return new Promise(resolve => {
//Fake a slow response from server
setTimeout(() => {
if (control.value == "adminh@gmail.com") {
console.log(control.value);
resolve({
"Email taken": true
});
} else {
resolve(null);
}
}, 2000);
});
}
}
Static checking is working fine. But I am not able to check with dynamic email coming from database. I am quite newbie to Ionic please help. thanks