I am working on an Ionic 3 App (Uses Angular 4). I am using Angularfire2 to interact with my Firestore database. Currently, I am retrieving a document as an observable and displaying it's fields in my template.
My problem is one of my fields in the document is a reference to another document (categories). from the template, I'm trying to do something like this:
<ion-badge>{{ getCategory( (pro.element | async)?.category ) }}</ion-badge>
which is calling a function in my provider that looks like this:
getCategory(ref:AngularFirestoreDocument<Category>){
if(ref){
ref.valueChanges().subscribe(val =>{
return val.name;
});
}
}
I have no idea if this is an appropriate/sustainable way to retrieve the reference document, as I have looked all over and not found any detailed documentation covering this. When I log this it seems to iterate over thousands of times, returning a DocumentReference
Object, but I get the error that valueChanges()
isn't a function.
Any direction on best practice in this circumstance would be greatly appreciated.
Thank you