I want to make a redirection of a pdf base64 with an a
tag, but when it is clicked it does nothing, also if I check it with the devtools of the browser and click on the href link it actually redirects me to the pdf
code:
<a [href]="fileSrc">a</a>
ts to get the source of the file getImgData() {
let chooseFile = document.getElementById(this.idF) as HTMLInputElement;
let imgPreview = document.getElementById(this.fileId) as HTMLEmbedElement;
let files = chooseFile.files[0];
if (files) {
this.globalFile = files;
let fileReader = new FileReader();
fileReader.readAsDataURL(files);
fileReader.addEventListener("load", function () {
imgPreview.src = this.result as any ;
})
return true
}else{
const dataTransfer = new DataTransfer();
if(this.globalFile != null)
if(chooseFile.files.length == 0)
dataTransfer.items.add(this.globalFile);
chooseFile.files = dataTransfer.files;
// chooseFile.files = this.globalFile;
return false
}
}
CodePudding user response:
Sounds like you just need some type of click event to make it fire.
<a [href]="fileSrc" (click)="openPdf(fileSrc)">a</a>
openPdf(fs) {
window.open(fs, '_blank');
}