I am developing a form that utilizes the data of the currently logged in user. The function responsible for setting the value of the form is executed before retrieving the user data.
ngOnInit() {
this.auth.getUserState()
.subscribe( user => {
this.user = user;
});
this.resetForm();
}
resetForm(form?: NgForm) {
if (form != null) { form.resetForm(); }
this.service.formData = {
who: this.user.email,
id: null,
name: '',
content: '',
date: null,
done: false
};
}
Is there a way to prevent "resetForm" from initializing before the component retrieves the current user data and properly populates the "who" field?