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
'@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { DocumentReference } from '@angular/fire/firestore';
import { Person } from '../models/person';
import { PersonService } from '../services/person.service';
@Component({
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 = this.formBuilder.group({
title: ['', Validators.required],
description: ['', Validators.required],
done: false
})
}
savePerson(){
if (this.personForm.invalid){
return;
}
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?