title: Sub-promises in AngularFire - selecting related children by ID?
body: <p>I have a json collection I've uploaded to my firebase, the sites and tools are related via arrays located in the former that point to keys in the latter</p>
  
  <pre><code>  "sites": {
      "s001": {
        "name": "ACT-105",
        "description": "Intro Accounting",
        "type": "course",
        "thumbnail": "debate",
        "toolCount": 4,
        "tools" : ["t001","t002","t003"]
      },
      "s002": {
        "name": "ART-201",
        "description": "Pottery Lab",
        "type": "course",
        "thumbnail": "sculpture",
        "toolCount": 4,
        "tools" : ["t001","t002","t003","t004"]
      },
    "tools": {
      "t001": {
        "name": "main-tool",
        "title": "Home",
        "description": "Main tool",
        "thumbnail": "home.jpeg"
      },
      "t002": {
        "name": "announce-tool",
        "title": "Announcements",
        "description": "System Announcements",
        "thumbnail": "announcements.jpeg"
      },
  </code></pre>
  
  <p>I open a url and promise; then grab the current site and its array of related tools in an array, then open another promise to loop through and get all the related tools.  From the alert, it appears to only grab one tool then quits. </p>
  
  <pre><code>    angular.module("foo", ["firebase"]).
     controller("MyCtrl", ["$scope", "angularFire", function($scope, angularFire) {
    var dbRef = "https://sampledb.firebaseio.com";
    var siteRef = new Firebase(dbRef + "/sites/s003");
    var promise  =  angularFire(siteRef, $scope, "site", {});
    var sitetools = [];
    promise.then(function() {
        sitetools = $scope.site.tools;
        alert("tools " + sitetools);
    }).then(function () {
  
        var toolList = [];
        for (var i=0;i&lt;sitetools.length;i++)
        {    
            alert("tool " + sitetools[i]);
            toolList.push(getTool(dbRef,toolId));
         }
         $scope.tools = toolList;
    });
    }]);
  
    var getTool = function(dbRef,toolId) {
    var toolitem;
    var toolRef = new Firebase(dbRef + "/tools/" + toolId);
    alert(toolRef);
    var promise  =  angularFire(toolRef, $scope, "tool", {});
    promise.then(function() {
        alert("found tool " + toolId);
        toolitem = $scope.tool;
    }); 
    return toolitem;
    };
  </code></pre>
  
  <p>The fiddle is here: <a href="http://jsfiddle.net/5n9mj/1/" rel="nofollow">http://jsfiddle.net/5n9mj/1/</a></p>