1

I have to show all images that are coming from a server as base64 strings. Thereofre I have created an array of images like this:

for (let i in json) {
        this.imageArray.push({
            imageUrl: json[i].datas
        })
     }

Now, I am trying to show these images from array in html file:

<ion-list no-lines>
   <ion-item *ngFor="let item of imageArray">
      <ion-img src="data:image/*;base64,{{item.imageUrl}}"></ion-img>
   </ion-item>
</ion-list>

But the images are not shown. What am I doing wrong?

2 Answers 2

1

Try this,

<ion-img *ngIf="item.imageUrl" [src]="'data:image/*;base64,'+item.imageUrl"></ion-img>
Sign up to request clarification or add additional context in comments.

6 Comments

i have an error like this Error: Quotes are not supported for evaluation! Statement: image/*;base64,+item.imageUrl located at ng:///home/GMS/src/pages/exerciseimage/exerciseimage.html@11:17
<ion-img [src]="'data:image/*;base64,'+item.imageUrl"></ion-img>
look images are come from the code that i have written in the question but the problem is that the image are come one time out of 10 time.. i hope you understand well
then you need to use ngIF
how to do it can you please suggest me??
|
0

You have to wrote the following code

<ion-list [virtualScroll]="imageArray">

  <ion-item *virtualItem="let item">
    <ion-img src="data:image/*;base64,{{item.imageUrl}}" style="height: 300px; width: 100%;"></ion-img>
  </ion-item>

</ion-list>

and in .ts file

 for (let i in json) {
        this.imageArray.push({
          imageUrl: json[i].datas
        })
      }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.