0
Gist Referring to the question
I have an Event class, and a method q is called snapdbEvents(), but when I put the object inside and try to define the values of the variables in the object occurs the following error:
Print by DB
0
Gist Referring to the question
I have an Event class, and a method q is called snapdbEvents(), but when I put the object inside and try to define the values of the variables in the object occurs the following error:
Print by DB
0
When assigning the values in the class it is recommended to use setters or a constructor, for example:
class export Evento {
id: string;
horaInicio: string;
horaFim: string;
constructor(values: Object) {
Object.assign(this, values);
// Ou
this.id = values.id;
this.horaInicio = values.horaInicio;
this.horaFim = values.horaFim;
}
setHoraInicio(horaInicio) {
this.horaInicio = horaInicio;
}
setHoraFim(horaFim) {
this.horaFim = horaFim;
}
}
and its attribution method in the Komponent or Provider:
private evento:Evento
chamaAPI() {
apiService.getEventos().subscribe(res => {
this.evento = new Evento(res.evento);
});
}
Browser other questions tagged angular firebase typescript
You are not signed in. Login or sign up in order to post.
you have already checked if the id property has any value? by error it is Undefined or without a defined type
– Lennon S. Bueno
Yes, I can print out all the data on the console.
– Kai
instead of using snapshot.key in the id tries to place a string manually only for testing then
– Lennon S. Bueno
I tried and gave the same thing,
– Kai
because the in id
id?:string
has the question and in others not– Lennon S. Bueno