Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda