Angularfire: Get the key of item pushed onto a list

Created on 18 Jul 2016  路  2Comments  路  Source: angular/angularfire

There was a closed issue for this #199 but changes in the push method mean the answer no longer works.
I am trying to do something like this but value is a promise and using preserveSnapshot on the list doesn't seem ideal:

const mylist = af.database.list('myFirebasePath');
const promise = mylist.push({key: val}).then((value) => {
console.log(value.$key);
} );

Most helpful comment

.push() does not return a Promise rather than a ThenableReference which contains the key value.

All 2 comments

let key = af.database.list('myFirebasePath').push{key:val}).getKey();

.push() does not return a Promise rather than a ThenableReference which contains the key value.

Was this page helpful?
0 / 5 - 0 ratings