how to convert byte array to image in Angular2

2019-06-10 23:11发布

问题:

I am getting byte array from api and i have applied image tag on my HTML page as <img src="data:{{model.asd_logo_type}};base64,{{model.dfgh_logo}}" alt="...">

but i am not able to get the image on display.

Please suggest what can i do.

回答1:

you can use src directive to display image in angular

<img [src]="'data:image/jpeg;base64,'+model.dfgh_logo" />

This is how I achieved. model.dfgh_logo this should have image in byte array.