Search code examples
angularfirebasegoogle-cloud-firestorereal-time-data

Get data from observabale firestoredocument


I have declared below variable

userDetails$: AngularFirestoreDocument<any>;

and below in service constructor

this.userDetails$ = this.firestore.collection('users').doc('key');

How can I get actual data from userdetails$?

Thanks


Solution

  • use valueChanges and subscribe to the observable.

     this.userDetails$.valueChanges().subscribe(value => {
        this.item= value 
      });;