Ich habe eine Liste von alumId
s, die ich in Firebase-Abfrage übergeben und Informationsbasis die IDs abrufen möchte. Im Moment habe ich einen Fehler, dass die for-Schleife nicht korrekt durchläuft.Abfrage innerhalb einer for-Schleife funktioniert nicht richtig
Erwartetes Ergebnis wird sein:
- Außerhalb für rootRef, 0
- Außerhalb für rootRef, 1
- Innerhalb von rootref, 0
- Innerhalb von rootref, 1
Tatsächliches Ergebnis:
- Außerhalb für rootRef, 0
- Außerhalb für rootRef, 1
- Innerhalb von rootref, 1
- Innerhalb von rootref, 2
for (var each = 0; each < alumAroundId.length; each++) {
console.log("outside of rootRef", each);
rootRef.child('users').child(alumAroundId[each].key).once('value', function (eventSnap) {
console.log(each, "inside the rootRef is off");
var thisUser = eventSnap.val();
thisUser.distance = alumAroundId[each].distance;
$scope.allAlumAround.push(thisUser);
});
}