Eric
Eric

Reputation: 2128

$firebaseArray inside of a $firebaseObject?

Using AngularFire, if I am using a $firebaseObject where one of the properties of the object is an array, is it possible to represent that array as a $firebaseArray so that I can access the API and use functions such as $add?

Upvotes: 0

Views: 136

Answers (1)

Mathew Berg
Mathew Berg

Reputation: 28750

"yes" but probably not how you're thinking. You can just get to that childnode if you're going to want it.

var parent = $firebaseObject(firebase.database().ref().child('parent'));
var children = $firebaseArray(firebase.database().ref().child('parent').child('children'));

If you need to wait for parent to load, hook into the $loaded()

$firebaseObject(firebase.database().ref().child('parent')).$loaded().then(function(parent){
    if(parent.children){
        parent.children = $firebaseArray(firebase.database().ref().child('parent').child('children'));
    }
});

Upvotes: 1

Related Questions