does not save date in firebase Angular 7


I'm starting with Angular and firebase and I had a problem recording information to firebase.

My model has it this way:

export interface Person
    nombre: string;
    apellido: string;
    jobDescription: string;
    createdDate: Date;
    lastModifiedDate: Date;

and I have a view model with the Id

export interface PersonViewModel
    id: string;
    nombre: string;
    apellido: string;
    jobDescription: string;
    lastModifiedDate: Date;

for the form-component.ts of saving person is in the following way ...

import { Component, OnInit } from '@angular/core';
import { FormControl, FormBuilder, FormGroup, Validators } from 
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { DocumentReference } from '@angular/fire/firestore';
import { Person } from '../models/person';
import { PersonService } from '../services/person.service';

 selector: 'app-person-form',
 templateUrl: './person-form.component.html',
 styleUrls: ['./person-form.component.css']
export class PersonFormComponent implements OnInit {

 personForm: FormGroup;

constructor(private formBuilder: FormBuilder,
 public activeModal: NgbActiveModal,
 private personService: PersonService) { }

ngOnInit() {
 this.personForm ={
   title: ['', Validators.required],
   description: ['', Validators.required],
   done: false
 if (this.personForm.invalid){
 let person: Person = this.personForm.value;
 this.personService.saveperson(person).then(response => 
 this.handleSuccessfulSavePerson(response, person))
 .catch(err => console.error(err))

When I check the console of the Firebase database, it does not appear neither createdDate nor lastModifiedDate ...

How can I solve this problem?

asked by ger 02.01.2019 в 21:55

0 answers