如何在嵌套的Firebase DB中获取子节点

时间:2018-09-25 03:34:56

标签: angularjs firebase firebase-realtime-database angularfire

enter image description here

嗨,我要只获取category =“ Tribal”的节点并将其作为Firebase数组对象返回。谢谢。

角度服务代码:

this.getSpecialTourPackage = function(){
 var dbRef = firebase.database().ref('states').child('itineraries');
 return $firebaseArray(dbRef);
};

角度控制器代码:

if(_category != undefined && _category == 'Tribal'){
    var loadedResult = [];
    var resultArray = indiaTourService.getSpecialTourPackage();
    resultArray.$loaded().then(function(data){
    data.forEach(item =>{
    loadedResult.push(item);
    $scope.itineraries = _.where(loadedResult,{ category : "Tribal"});
    });
  });
}

0 个答案:

没有答案