My challenge involves displaying an array of images using a *ngFor loop.
itemimg.component.html
<div *ngFor="let itemimg of itemimgs" [class.selected]="itemimg === selectedItemimg"
(click)="onSelect(itemimg)">
<img id="{{itemimg.index}}" class="thumb" src="{{itemimg.imageUrl}}" width="{{itemimg.width}}" height="{{itemimg.height}}"
style="float: left; margin-right: 3px; margin-bottom: 3px">
</div>
My goal is to replace the first image when any of the displayed images are clicked.
itemimg.components.ts (part)
onSelect(itemimg: Itemimg): void{
this.selectedItemimg = itemimg;
var newsrc = "../../assets/images/" + itemimg.route + ".jpg";
//alert (newsrc);
*what-goes-here* = newsrc; // the problem
}
I have been searching online for over three hours without finding a solution to my issue. Appreciate your assistance in advance.