showDownloadDialog() {
const subscription = this.alert.custom("Cancel")
.subscribe(() => {
this._ngUnsubscribe.unsubscribe();
subscription.unsubscribe();
});
}
download() {
this.showDownloadDialog();
this._ngUnsubscribe = this.download(this._filterParams).pipe(
take(1),
catchError(() => {
return observableOf();
})).subscribe((res) => {
/*
* const options = {
* headers: headers,
* responseType: 'arraybuffer'
* };
* /
this._alertWindow.close();
const file = new Blob([res]);
const url = URL.createObjectURL(file);
const link = document.createElement("a");
const fileName = `aa.txt`;
link.setAttribute("href", url);
link.setAttribute("target", "_blank");
link.setAttribute("download", fileName);
link.click();
});
}
angular 6 download files and cancel http request
最新推荐文章于 2022-07-25 19:58:51 发布