Show images in cards from bytes

Hi. I’d like to show an image from an array of bytes. I tried this code but it doesn’t work:

<ion-card *ngFor="let result of results">
    <ion-card-header>
      <h2>{{result.title}}</h2>
    </ion-card-header>
    <ion-card-content>
      <img ng-src="data:image/JPEG;base64,{{result.arrayofbytes}}"/>
    </ion-card-content>
  </ion-card>

Static files must not be public in my application, so I don’t need something like this:

<img src="http://www.myserver.it/images/photo.jpg"/>

Any ideas?

1 Like

Your problem is with ng-src, that’s Angular 1 syntax. Here’s the Angular 2 syntax:

<img [src]="'data:image/JPEG;base64,' + result.arrayofbytes" />
1 Like

It works, thank you!