Right now, I am unwrapping my data using the method described in the
documentation
<https://github.com/angular/angularfire2/blob/master/docs/2-retrieving-data-as-objects.md#retrieving-the-snapshot>.
However, the documentation states:
*AngularFire2 unwraps the Firebase DataSnapshot by default*, but you can
> get the data as the original snapshot by specifying the preserveSnapshot
> option.
How would I be able to access the "default" unwrapping functionality (read:
access the elements of `item`) without having the manually unwrap the data
snapshot?
My data from Firebase looks like this:
{
testObj : {
firstName: "beckah",
lastName: "s"
}
}
My code (which works) is:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { AngularFireDatabase, FirebaseObjectObservable } from
'angularfire2/database';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
item: FirebaseObjectObservable<any>;
constructor( public navCtrl: NavController,
public db: AngularFireDatabase ) {
this.item = db.object('/testObj', { preserveSnapshot: true });
this.item.subscribe(snapshot => {
console.log(snapshot.val())
});
}
}
Which outputs
Object {firstName: "beckah", lastName: "s"}
How would I be able to do the exact same thing (console.log my item object)
without manually unwrapping my snapshot like the documentation states is
possible?
Is there some kind of `this.item.get("firstName")` method?
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.