I am probably missing some basics, hopefully this question is not too dumb...
I am trying to retrieve data from a document stored in FireStore. I am following the example provided here: https://github.com/angular/angularfire2/blob/master/docs/firestore/documents.md
What I am wondering: After having access to the document:
this.itemDoc = afs.doc<Item>('items/1');
this.item = this.itemDoc.valueChanges();
How can I retrieve data from that document? I don't want . to use it in my html, but get the data from some fields and do something with it in TypeScript.
Obviously this.item is not an array so item[0].fieldname doesn't work...
TIA.
this.item
is an observable, you need to subscribe
to get the data.
this.itemDoc = afs.doc<Item>('items/1');
this.item = this.itemDoc.valueChanges();
this.item.subscribe(res=>{
console.log(res.fieldname);
}