$ firebaseArray $ $ firebaseObject里面?

时间:2017-01-05 13:56:54

标签: angularjs firebase angularfire

使用AngularFire,如果我使用$firebaseObject,其中对象的一个​​属性是数组,是否可以将该数组表示为$firebaseArray,以便我可以访问API和使用$add

等功能

1 个答案:

答案 0 :(得分:1)

“是”,但可能不是你的想法。如果您想要它,您可以直接访问该子节点。

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

如果您需要等待父级加载,请挂钩$loaded()

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