This would help (as it always happens) to understand the use case that we are trying to solve, and not just the solution you chose for this problem - there are often simpler ways to approach the set of problems (see What is the XY problem? ).
There is nothing in AngularFire to handle nested list lists. A list of specific items will actually be a little simpler than a few lists that the list refers to.
Firebase.util
A tool called Firebase.util exists to help with denormalization (it is currently getting revved to V2, which should come out in a month or two), and it is compatible with AngularFire:
var fbRef = new Firebase(URL); var indexRef = fbRef.child('users/' + userId + '/lists'); var dataRef = fbRef.child('lists'); var joinedRef = Firebase.util.intersection(indexRef, dataRef); var lists = $firebase( joinedRef ).$asArray();
Angular only
An angular - the only approach is to load lists manually and use AngularFire for individual lists:
app.factory('NestedList', function($firebase, $timeout) { return function(indexRef, dataRef) { var hashOfLists = {}; indexRef.on('child_added', function(snap) { var key = snap.key(); var list = $firebase( dataRef.child(key).$asArray(); hashOfLists[key] = list; }); indexRef.on('child_removed', function(snap) { $timeout(function() { delete hashOfLists[snap.key()]; }); }); return hashOfLists; } });
note that this example uses snap.key (), but this only applies when using the 2.x SDK version, which was released only this week; prev versions should use snap.name ()
For more complex operations and creating your own directives or services, check out the question and answer here . Although this may not seem at first glance, this is a fairly detailed discussion of how to receive any Firebase data and convert it to any proprietary structure.
source share