Project: Trying to create a simple image gallery. One main image placeholder, that changes its image to be have the same src as a corresponding thumbnail image that has been clicked.
Example in plain JS: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_tab_img_gallery
Code:
<div *ngIf="images">
<div *ngFor="let image of images"> //images array
<img #productThumbnail [src]='image.fields.file.url'
(click)='thumbnailClicked()'>
<div *ngIf='showImage'>//simple function that shows the image
<img src={{productThumbnail.src}}>
</div>
(image.fields.file.url is an external array (array name: images) of image URLs)
Problem: When the images array is populated many array items will be given the reference #productThumbnail
This results in the main image placeholder retrieving the src of every thumbnail, because they all have the same reference of #productThumbnail. I just need the thumbnail that has been clicked on.
I hope this makes some sense. Any help is really appreciated.