I am using some AngularJS to retrieve values in my Firebase Database under a specified parent tree. I would like to get also the value of this parent.
My database structure:
So far, my code gets the Name and PhotoUrl of each tripID under a specified UserID. But I would like to get the TripID value as well as the Name and PhotoUrl. The problem is that the TripID value is not in the child tree. How can I retrieve it ?
My JS looks like this:
var app = angular.module('test', []);
app.controller('MainCtrl', function($scope) {
var database = firebase.database();
database.ref(`trips/${userid}/trips`).once('value')
.then(photosSnap => {
var photosObj = photosSnap.val();
var tripName = Object.keys(photosObj).map(key => photosObj[key].name);
var tripPhotoUrl = Object.keys(photosObj).map(key => photosObj[key].photourl);
$scope.repeatData = tripName.map(function (value, index) {
return {
data: value,
value: tripPhotoUrl[index]
}
});
