I am hoping you can help. I posted a question on Slack but sometimes people are not too helpful.
I want to retrieve the field total from the database. The problem I have having is that the Observable is returning the value after I console it.
How can I get the subscribe line to wait until the data.total has been returned?
checkAvailability(){
var itemDoc: AngularFirestoreDocument<any>;
var count: Observable<any>;
var count2: Number;
itemDoc = this.afs.doc(`classTotal/SessionA-5thGrade`)
count = itemDoc.valueChanges()
count.subscribe((data) => {this.totalRecCount = data.total } ); <-- This Line
//.subscribe((data) => {this.totalRecCount = data.total} );
//.subscribe((res) => { this.totalRecCount = res.total; console.log('Count2: ', res.total)});
console.log('Count3: ', count.subscribe(data => {this.totalRecCount = data.total; console.log("Total Count: ",this.totalRecCount)} ));
return true;
}