Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

html5 download tag not working angular

// Angular Solution

//html
<button type="button" class="btn btn-sm btn-warning"
(click)="downloadArchiveFile(item.file_name, downloadSrc+item.url)">
Download
</button>

//typescript
import { HttpClient } from '@angular/common/http';
///
constructor(private http: HttpClient) {}
///  

downloadArchiveFile(name: string, url: string) {
 this.loader.start();
 this.http.get(url, { responseType: 'blob' })
 .subscribe((data: any) => {
   this.loader.stop();
   console.log(data);
   this.download(name, data);
  }, (error) => {
    this.loader.stop();
    this.toastr.error(error, "Something Went Wrong");
  });
}

download(name, blob) {
 let link = document.createElement("a");
 link.download = name;
 link.href = URL.createObjectURL(blob);
 link.click();
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: map typescript 
Typescript :: angular subscribe catch stat 
Typescript :: typescript get object value 
Typescript :: import openzeppelin contracts in remix 
Typescript :: Scriptsactivate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at 
Typescript :: angular http 
Typescript :: how to make space equal between elements in a linearlayout android studio 
Typescript :: ++i vs i++ 
Typescript :: c program to find sum of array elements using recursion 
Typescript :: angular set query params 
Typescript :: typescript import particular class from file 
Typescript :: how to check if there is any point which lies inside the circle 
Typescript :: TYPESCRIPT RETURN HTML ELEMENT 
Typescript :: 10 digit mobile number validation pattern in javascript 
Typescript :: warning: failed prop type: the prop `history` is marked as required in `router`, but its value is `undefined`. 
Typescript :: when to stop testing 
Typescript :: set type for usecontext 
Typescript :: laravel unique working with softdeletes 
Typescript :: adding two lists using lambda function 
Typescript :: latex two plots in 1 
Typescript :: typescript declare process.env 
Typescript :: how long does it take to learn typescript 
Typescript :: router params angular 
Typescript :: fgets input from user 
Typescript :: rule::exists with custom message laravel 
Typescript :: typescript get promise allsettled 
Typescript :: javascript block comment 
Typescript :: typescript function return type observable 
Typescript :: beziere curve function 
Typescript :: [(ngModel)] input error 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =