title: Angularjs and Displaying Nested Json Arrays
body: <p>New to angularjs and looking for some advice.   We have hooked our angular front-end to a REST API that is spitting json back such as:</p>
  
  <pre><code>[  
     {  
        "category_id":"1",
        "category_name":"dog",
        "subcategories":[  
           {  
              "category_id":"4",
              "parent_id":"1",
              "category_name":"Sporting",
           },
           {  
              "category_id":"5",
              "parent_id":"1",
              "category_name":"Hunter",
           },
           {  
              "category_id":"6",
              "parent_id":"1",
              "category_name":"Lap",
           }
        ]
     },
     {  
        "category_id":"2",
        "category_name":"feline",
        "subcategories":[  
           {  
              "category_id":"8",
              "parent_id":"2",
              "category_name":"Black",
           },
           {  
              "category_id":"9",
              "parent_id":"2",
              "category_name":"White",
           },
           {  
              "category_id":"10",
              "parent_id":"2",
              "category_name":"Domestic",
           }
        ]
     }
  ]
  </code></pre>
  
  <p>We are trying display each category and their sub-categories as rows in a table.   We have been trying to us ng-repeat - but it definately doesn't like nested arrays when using tables.</p>
  
  <p>We have hacked something like this together:</p>
  
  <pre><code>&lt;tr ng-repeat-start="cat in category"&gt; 
      &lt;td&gt;{{cat.category_id}}&lt;/td&gt;
      &lt;td&gt;{{cat.category_name}}&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr ng-repeat-start="subcat in cat.subcategories"&gt;
      &lt;td&gt;{{subcat.category_id}}&lt;/td&gt;
      &lt;td&gt;{{subcat.category_name}}&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr ng-repeat-end&gt;&lt;/tr&gt;
  &lt;tr ng-repeat-end&gt;&lt;/tr&gt;
  </code></pre>
  
  <p>What we would like to be able to do is use datatable (angular-datatables.min.js) functionality for our tables which means that we need to flatten our our json such that subcategories are on the same "level" as categories and are all in one array instead of subarrays.</p>
  
  <p>Does anyone know of a 'nice' way to accomplish this?</p>
  
  <p>Thanks in advance for any assistance.</p>