title: AngularJS nested routing
body: <p>I'm working a fairly simple AngularJS project with some deep route nesting to select from a nested data structure:</p>
  
  <pre><code>angular.module('doccat', []).
   config(['$routeProvider', function($routeProvider) {
       $routeProvider.
           when('/',                    { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           when('/:p0',                 { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           when('/:p0/:p1',             { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           when('/:p0/:p1/:p2',         { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           when('/:p0/:p1/:p2/:p3',     { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           when('/:p0/:p1/:p2/:p3/:p4', { templateUrl: 'partials/detail.html', controller: DocDetailCtrl }).
           otherwise({ redirectTo: '/' });
   }]);
  
  function DocDetailCtrl($scope, $routeParams) {
     var path = [];
     if ($routeParams.p0) path.push($routeParams.p0);
     if ($routeParams.p1) path.push($routeParams.p1);
     if ($routeParams.p2) path.push($routeParams.p2);
     if ($routeParams.p3) path.push($routeParams.p3);
     if ($routeParams.p4) path.push($routeParams.p4);
  
     // do stuff with  path
  }
  </code></pre>
  
  <p>This has up to 5 layers in the path, which should be plenty for my purposes, so it is good enough for now. However, the underlying data <em>could</em> be nested arbitrarily deep, which would require arbitrary routing. <br/>
  I think the ideal for this would be a route that says 'all the rest of the path goes to any array of parameters', but it doesn't look like there is a way to do anything like that in AngularJS. Just for the sake of completeness, does anyone know of a way to do this?</p>