title: Angular 2 - File download - without any backend help -Possible?
body: <p>Am playing with Angular 2, trying to create sample app to showcase myself and i've completed almost all things. Finally, am trying to implement download option. for that, i dig SO and i got <a href="https://stackoverflow.com/questions/35368633/angular-2-download-pdf-from-api-and-display-it-in-view/48467727#48467727">this</a></p>
  
  <p>as per that example i try to replicate it, but came to know that <strong>HTTP_PROVIDERS</strong> got deprecated. Could some one tell me what is equivalent module available currently. And guide me to get start.</p>
  
  <p>Kindly pls share any working plunker for reference</p>
  
  <p>so far i have below</p>
  
  <pre><code>import { Http, ResponseContentType } from '@angular/http';
  export class AboutComponent implements OnInit {
  
    //constructor() { }
    constructor(private dataService: dataService,private http: Http){}
    about=[];
    private filePath = './coreMachineDetails/machine109902.docx' // docx in my local folder      
     ngOnInit(){
      //some codes
    }
  
    getFile(){
      return this.http.get(this.filePath,{
        responseType: ResponseContentType.Blob,     
      }).map(res =&gt;{
            return {
          filename: 'machine109902.docx',
          data: res.blob()
        };
      }).subscribe(res =&gt; {
          console.log('start download:',res);
          var url = window.URL.createObjectURL(res.data);
          var a = document.createElement('a');
          document.body.appendChild(a);
          a.setAttribute('style', 'display: none');
          a.href = url;
          a.download = res.filename;
          a.click();
          window.URL.revokeObjectURL(url);
          a.remove(); // remove the element
        }, error =&gt; {
          console.log('download error:', JSON.stringify(error));
        }, () =&gt; {
          console.log('Completed file download.')
        });
    }
  }
  </code></pre>
  
  <p>in view</p>
  
  <pre><code>&lt;button class="btn waves-effect waves-light btn-primary custom-btn" (click)="getFile()"&gt;&lt;i class="fa fa-file-pdf-o"&gt;&lt;/i&gt; Download manuals&lt;/button&gt;
  </code></pre>