title: AngularJS: How to open a file in a new tab?
body: <p><kbd><a href="http://plnkr.co/edit/Tfv2ZA5yfatuoX6bazX9?p=preview" rel="nofollow noreferrer"><strong>LIVE DEMO</strong></a></kbd></p>
  
  <p>Given a URI of a file, I'd like to open it <strong>in a new tab</strong> (not a new window).</p>
  
  <p><a href="https://stackoverflow.com/a/23415303/247243">It looks like</a> <strong>it is not possible</strong> to use <code>$window.open(uri, '_blank')</code>.</p>
  
  <p>So, I tried the following trick:</p>
  
  <pre><code>var link = angular.element('&lt;a href="uri-here" target="_blank"&gt;&lt;/a&gt;');
  angular.element(document.body).append(link);
  link[0].click();
  link.remove();
  </code></pre>
  
  <p>and <a href="http://jsbin.com/cuhekeve/1/edit" rel="nofollow noreferrer">it works</a>.</p>
  
  <p>But, if I put exactly the same code in a promise callback, it doesn't work anymore (it opens the file in a new window instead).</p>
  
  <p>Any idea what's going on here?</p>
  
  <p><kbd><a href="http://plnkr.co/edit/Tfv2ZA5yfatuoX6bazX9?p=preview" rel="nofollow noreferrer"><strong>PLAYGROUND HERE</strong></a></kbd></p>