I'm trying to display an image on new window after clicking on button.
However, some time, that cannot be done.
Component.ts
displayMyImage()
{
this.http.get(this.imagePath, {observe: 'response', responseType: 'blob'}).pipe(map(res =>
{
return new Blob([res.body], {type: res.headers.get('Content-Type')});
})).subscribe(hi =>
{
const xx = URL.createObjectURL(hi);
window.open(xx);
});
}
Component.html
<span (click)='displayMyImage()'>Display</span>
or
<button (click)="displayMyImage()">Display</button>
I got that exception
Could you please tell me what I missed ?. Big thanks.