My component has a form. My services handle the queries, saves and deletes. When a form is edited, the component has a save form function which calls the service to save the data. That works fine. However, upon saving I would like to mark the form as pristine. I don't believe my attempt is correct, as the set line in the service can be removed and the form will still be marked as pristine when saving.
Component
async saveForm(){
await this.service.saveForm(form.value);
this.form.markAsPristine();
}
Service
public async saveForm(value: Form) {
this.afs.doc<Form>(`path`).set(formValue, {merge: true })
}
try using promise chaining from your service and component
service:
public async saveForm(Form) {
this.afs.doc<any>(`path`).set(formValue, {merge: true }).then((result)=>{
return result
})
component:
this.yourservice.saveForm(form.value).then((result)=>{
if(result){
this.form.reset();
}
})
this is promise chaining - after reviewing this with the questioner the answer changed to resetting the form.