【问题标题】:$firebaseArray inside of a $firebaseObject?$firebaseObject 内的 $firebaseArray?
【发布时间】:2017-01-05 23:04:22
【问题描述】:

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

【问题讨论】:

    标签: angularjs firebase angularfire


    【解决方案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'));
        }
    });
    

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2016-04-20
      • 2017-08-14
      • 2015-12-09
      • 2016-11-25
      • 2017-09-04
      • 1970-01-01
      • 1970-01-01
      • 2016-07-28
      相关资源
      最近更新 更多