简体   繁体   中英

Include $key in angularfire2 v5

Actually i need to get the $key in this AngularFireList, but i don't know how i do that, actually this is my code to a list, that works but don't rerieve the data with the $key:

getAutosByPlaca(placac: string): Observable<Auto[]> {
 const placa$ = new Subject().startWith(placac);
 return placa$.switchMap(placa => {
  return this.db.list(this.dbPath, ref => ref.orderByChild('placa').equalTo(placac)).valueChanges();
 });
}

valueChanges() returns the unpacked data. To get the meta data, you need snapshotChanges(), as documented here:

https://github.com/angular/angularfire2/blob/master/docs/rtdb/lists.md#angularfireaction---action-based-api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM