title: How to display an image or pdf file on new tab in angular js?
body: <p>Below is my page:</p>
  
  <p><img src="https://i.stack.imgur.com/wNw1Q.png" alt="enter image description here"></p>
  
  <p>Now when i click on Capture1.png i want to first display that image on new tab without any pop up as shown in my above picture.</p>
  
  <p>Same way when i click on sample.pdf i want to first display pdf on new tab.</p>
  
  <p>This is my html:</p>
  
  <pre><code>    &lt;div ng-controller="MyController"&gt;
  &lt;a target="_blank" href="/Account/FetchFile/{{File_Id}}" ng-click="OpenFile(File_Id)" style="line-height:20px"&gt;Capture1.png&lt;/a&gt;
  &lt;a target="_blank" href="/Account/FetchFile/{{File_Id}}" ng-click="OpenFile(File_Id)" style="line-height:20px"&gt;sample.pdf&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>var app = angular.module('MyController', ['ur.file', 'ngResource']);
  
  app.controller('MyController', function ($scope, $resource, $http,$window) {
        var url = "http://localhost:47000/Account/FetchFile/" + fileId;
        $window.open(url, '_blank');
  }
  </code></pre>
  
  <p><strong>Server side:</strong></p>
  
  <pre><code>public FileContentResult FetchFile(int id)
          {
              byte[] fileContent = null;
              string fileType = "";
              string fileName = "";
  
              var file = GetFileByID(id);
  
              if (file != null)
              {
                  fileContent = file.Data;
                  fileType = file.ContentType;
                  fileName = file.FileName;
  
                  return File(fileContent, fileType, fileName);
              }
  
              return null;
          }
  </code></pre>
  
  <p><strong>Now here problem is when i single click on capture1.png then two tabs are open with the pop up(like i shown in the above image) on my page(with option open and save) and 2 tabs get closed and those 2 pop ups appear on my same page as shown in my image</strong>.</p>
  
  <p>Can anybody figure out whats the problem??</p>