title: AngularJS compile and render HTML code from file
body: <p>There is the following code of my custom directive:</p>
  
  <pre><code>angular.module('app.directives', []).directive('userHeader', ['authService', '$compile', function(authService, $compile) {
    return {
      restrict: 'AEC',
        link: function(scope, elem, attrs) {
          var html;
          if (authService.currentUser()) {
            html = $compile("&lt;h1&gt;You successfully entered, dear {{ user.name }}!&lt;/h1&gt;")(scope);
            elem.replaceWith(html);
          } else {
            html = $compile("&lt;h1&gt;You didn't enter&lt;/h1&gt;")(scope);
            elem.replaceWith(html);
          }
  
          return scope.user = authService.currentUser();
        }
      };
    }
  ]); 
  </code></pre>
  
  <p>So,as you can see, I render some HTML code using condition. But it's example, in my real application HTML code is much bigger, and I want to move HTML code from directive to template. But how can I compile  HTML code from template in this case? Thanks in advance</p>