I have the code below where I need to display an image coming from the database, the image is coming here as a byte how to display this image on the screen?
<!-- Listar As Bebidas Alcoólicas -->
<div class="card-columns" *ngIf="bebidasAlcoolicas != null">
<div class="card" *ngFor="let bebidaAlcoolica of bebidasAlcoolicas">
<button type="button" class="btn btn-danger" (click)="incluirCarrinhoBebidaAlcoolica(bebidaAlcoolica)">
<img class="card-img-top" src="bebidaAlcoolica.imagemBebidaAlcoolica" alt="Card image cap">
</button>
<div class="card-body">
<h5 class="card-title text-primary font-weight-bold">{{bebidaAlcoolica.nomeBebidaAlcoolica}}</h5>
<p class="card-text text-danger">{{bebidaAlcoolica.valorBebidaAlcoolica | currency:'BRL':true}}</p>
</div>
</div>
</div>
Attempt 2:
request-avulso.create-component.ts
loadImagem(encryptedImage) {
this.imageData = 'data:image/png;base64,' + encryptedImage;
this.sanitizedImageData = this.sanitizer.bypassSecurityTrustUrl(this.imageData);
console.log(this.sanitizedImageData);
}
request-avulso.create-component.html
<!-- Listar As Bebidas Alcoólicas -->
<div class="card-columns" *ngIf="bebidasAlcoolicas != null">
<div class="card" *ngFor="let bebidaAlcoolica of bebidasAlcoolicas">
<button type="button" class="btn btn-danger" (click)="incluirCarrinhoBebidaAlcoolica(bebidaAlcoolica)">
<img class="card-img-top" [src]='sanitizedImageData' *ngIf="loadImagem(bebidaAlcoolica.imagemBebidaAlcoolica)" alt="Card image cap">
</button>
<div class="card-body">
<h5 class="card-title text-primary font-weight-bold">{{bebidaAlcoolica.nomeBebidaAlcoolica}}</h5>
<p class="card-text text-danger">{{bebidaAlcoolica.valorBebidaAlcoolica | currency:'BRL':true}}</p>
</div>
</div>
</div>