title: How to do recursive directive with $templateCache?
body: <p>I was trying to use <a href="https://github.com/eu81273/angular.treeview" rel="nofollow">angular.treeview</a> to display a tree structure, and it works just fine. However, it causes infinite loop when I use $templateCache to make it more maintainable.  It looks like using a string to store the template removes the outermost loop in the recursive calls that is not happening with template retrieved from $templateCache. You will see the problem after commenting out the second line (line #88 in angular.treeview.js) in my example at <a href="http://plnkr.co/edit/khQ7BMPRYedK6B1PVlDY?p=preview" rel="nofollow">http://plnkr.co/edit/khQ7BMPRYedK6B1PVlDY?p=preview</a>.</p>
  
  <pre><code>$log.log('cache:' + templateCache.get('treeNode.html'));
  //template = templateCache.get('treeNode.html
  $log.log('string:' + template);
                      //Rendering template.
                      element.html('').append( $compile( template )( scope ) );
  </code></pre>
  
  <p>The other question if I can get $templateCache work is how to replace variables in the template before it's compiled?  I'd like to replace those variables like treeModel and nodeChildren in the template to make the code more flexible. </p>