I am trying to bind a byte array to an image tag in angular. I know the byte array is correct, because I can download it and view it from my API.
I created an image like this:
<img [src]="src" />
and then in my code, I sanitized the byte array like this:
this.src = this.sanitizer.bypassSecurityTrustResourceUrl(`data:image/svg+xml,${this.location.qrCode}`);
in my console I can see this:
But the image isn't displaying. What am I doing wrong?
I have tried a few other things:
const reader = new FileReader();
reader.onload = (e) => (this.src = this.sanitizer.bypassSecurityTrustResourceUrl(e.target.result.toString()));
reader.readAsDataURL(new Blob([this.location.qrCode]));
and
this.src = this.sanitizer.bypassSecurityTrustResourceUrl(`data:image/svg+xml;base64,${this.test}`);
and
this.src= btoa(this.location.qrCode);
and
const reader = new FileReader();
reader.onload = (e) => (this.src = e.target.result);
reader.readAsDataURL(new Blob([this.location.qrCode]));
None of them worked :(