I am executing the following Firebase query:
var getAdmin = function() {
var rootRef = new Firebase(FIREBASE_URI),
adminList = [],
deferred = $q.defer();
rootRef.child('user').orderByChild('role').startAt(21).once('child_added', function (administrator) {
// Add each Administrator to Admin List
adminList.push(administrator);
});
// deferred.resolve(?)
return deferred.promise;
};
I want to resolve the promise with the list of Administrators. How do I detect when the Firebase snapshot has been fully executed?