Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Angular / Firestore - Set Reactive Form to pristine after saving document

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 })
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!