/ / firestore.FieldValue.serverTimestamp () w reaktywnym resetowaniu formularzy - kątowe, maszynopis, firebase, google-cloud-firestore, formularze reaktywne pod kątem

firestore.FieldValue.serverTimestamp () w reaktywnym resetowaniu formularzy - kątowe, maszynopis, firebase, google-cloud-firestore, formularze reaktywne pod kątem

Mam formularz reaktywny, który tworzy dokument w Firestore. Dodałem znacznik czasu w jednej z wartości grupy formularzy, ale gdy formularz zostanie zresetowany i ponownie wyślę wartości w polu estado i fecha dostaję null.

Tutaj mój stackblitz: https://stackblitz.com/edit/angular-uubb7t

wprowadź opis obrazu tutaj

this.forma = fb.group ({
valorPropiedad: [ 100000, Validators.required ],
nombre: [ "", Validators.required ],
email : [ "", [Validators.required, Validators.email] ],
celular: [ "",  [Validators.required, Validators.maxLength(9)] ],
acepta : [ false, Validators.requiredTrue ],
fecha: [ firebase.firestore.FieldValue.serverTimestamp() ],
estado: [ false ]
});

Odpowiedzi:

0 dla odpowiedzi № 1

Mógłbym rozwiązać to za pomocą tego kodu, nie wiem, czy to będzie najlepsze, ale działa dla mnie:

this.form.resetForm({
fecha: firebase.firestore.FieldValue.serverTimestamp(),
estado: false
});

sprawdź mój stackblitz: https://stackblitz.com/edit/angular-uubb7t