gurkis gurkis - 6 months ago 44
Javascript Question

Display 10 unique pictures from inside a ngFor loop

I am using *ngFor to repeat a img tag trying to show 10 unique pictures from the unsplash API. My code looks like this:

<div *ngFor="let a of myArray; let index = index">
<div class="thumbnail">
<img src={{a}}>

myArray consist of 10 strings with the same link: where x is taken from a user input field. An example of x could be nature or food. Every time I go to I get a different picture displayed but in my app it shows the same picture 10 times.

It seems like my app is only accessing the link one time and then repeats the image 10 times, how do i make it so the 10 images are all unique?


It should be: <img src={{a.url}}> where a is each item in your myArray array.