title: Conditionally add target="_blank" to links based on href, even when the href is interpolated
body: <p>There is a similar question out there, but it only applies to hard-coded hrefs, not ones that are interpolated by angular.  See <a href="https://stackoverflow.com/questions/23584201/conditionally-add-target-blank-to-links-with-angular-js">Conditionally add target=&quot;_blank&quot; to links with Angular JS</a></p>
  
  <p>The solution I'm looking for is best illustrated by the following directive:</p>
  
  <pre><code>yourModule.directive('a', function() {
    return {
      restrict: 'E',
      link: function(scope, elem, attrs) {
        var a = elem[0];
        if (location.host.indexOf(a.hostname) !== 0)
          a.target = '_blank';
      }
    }
  }
  </code></pre>
  
  <p>The problem is that the directive runs before angular has done any interpolation, and therefore all links appear relative.  Is there a clean way to do this?  I can't use mutation observers, because I must support IE9.</p>