I'm creating form which is using data of the current logged in user. Function which is setting value of form is done before getting 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
};
}
How can i stop initialization of "resetForm" before component get current user data and complete "who" field with properly value?