I'm using AngularFire with Firebase and am wanting to get the key of the element that I just added via the $add() method. There's a documented way to do this with "vanilla" Firebase, see "Getting the Unique ID Generated by push()" here. It doesn't seem to work with AngularFire's equivalent of $id, though.
var ref = $firebase(firebaseData.ref()).$asArray();
var newItem = ref.$add({fruit: "apple", color: "red"});
var itemId = newItem.$id;
// Do stuff with itemID...
newItem is successfully added to Firebase with a new key (such as -Jf-06c0QX_vMMNL3Aek), but itemId returns undefined.
Is there a way to do this?