Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

201
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda