How can I use Angular to display a preview of the selected image? Currently, when we click, all images are selected. Does anyone have suggestions on how to show the preview of only the selected image and unselect the previously selected one when a new image is chosen?
public images: Array<object> = [
{
src: 'https://picsum.photos/250/250/?image=110',
description: 'Luxury hotel stay',
price: 250
},
{
src: 'https://picsum.photos/250/250/?image=58',
description: 'Excursion to discover island animals',
price: 160
}
];
HTML:
<div class="image__container" [ngClass]="{ 'selected': selected }">
<img class="image" [src]="item.src">
<div
class="image__description"
(click)="selected = !selected"
>
<div class="image__description--content">
<div class="image__description--price">
{{ item.price }}
</div>
</div>
</div>