title: Generate HTML string from AngularJS template string
body: <p>I have angularjs template as a string including "ng-repeat" and other directives. I want to compile it in the controller to produce the result HTML as string.</p>
  
  <p>Example on what I want to apply in Angular:</p>
  
  <pre><code>Input:
  -------
  var template = '&lt;div ng-repeat="item in items"&gt;{{item.data}}&lt;/div&gt;';
  
  Output:
  --------
  var result = '&lt;div&gt;1&lt;/div&gt;&lt;div&gt;2&lt;/div&gt;&lt;div&gt;3&lt;/div&gt;&lt;div&gt;4&lt;/div&gt;';
  </code></pre>
  
  <p>I want this to be done in the controller I've and I tried the following:</p>
  
  <pre><code>var template = '&lt;div ng-repeat="item in items"&gt;{{item.data}}&lt;/div&gt;';
  var linkFunction = $compile(template);
  var result = linkFunction($scope);
  
  console.log(result); // prints the template itself!
  </code></pre>
  
  <p>Thanks!</p>