title: Getting Compiled HTML from AngularJS
body: <p>I'm having trouble getting the compiled html of a page in AngularJS. Here's the code:</p>
  
  <p>JS:</p>
  
  <pre><code>    &lt;script src="http://code.angularjs.org/1.2.0rc1/angular.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          var app = angular.module('main', []);
  
          app.directive("compile", ['$compile', function ($compile) {
              return {
                  link: function(scope, elem, attr){
                      var compiledHTML = $compile(elem.contents())(scope);
                      console.log(compiledHTML);
                      var returnString = '';
                      for(i=0; i&lt;compiledHTML.length; i++)
                          returnString += compiledHTML[i].outerHTML;
  
                      console.log(returnString);
                  }
              };
          }]);
      &lt;/script&gt;
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;html ng-app="main" compile&gt;
      &lt;body&gt;
          {{3 + 4}}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What is strange is in the first console.log(), it shows the compiled data, 7, in the outerHTML property, but when I output all the .outerHTML, it shows the uncompiled version, {{3 + 4}}</p>