I want to display the visited countries in the dropped list (where have you been) How to solve this in my Ionic App https://mytopcountries.web.app/tabs/home
<div class="example-container">
<h2>Where have you been</h2>
<div cdkDropList #doneList="cdkDropList" [cdkDropListData]="done" [cdkDropListConnectedTo]="[todoList]"
class="example-list" (cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of done" cdkDrag>
<div class="flag-box">
<img [src]="item.url" alt="flag image">
<p>{{ item.name }}</p>
</div>
</div>
</div>
</div>
</div>
done = [
{url: 'https://www.countryflags.io/ad/shiny/64.png', name: 'Andorra' },
{url: 'https://www.countryflags.io/ae/shiny/64.png', name: 'UAE' },
{url: 'https://www.countryflags.io/at/shiny/64.png', name: 'Austria' },
{url: 'https://www.countryflags.io/au/shiny/64.png', name: 'Australia' },
{url: 'https://www.countryflags.io/aw/shiny/64.png', name: 'Aruba' },
{url: 'https://www.countryflags.io/bg/shiny/64.png', name: 'Bulgaria' },
{url: 'https://www.countryflags.io/ch/shiny/64.png', name: 'Switzerland' },
{url: 'https://www.countryflags.io/cn/shiny/64.png', name: 'China' },
];
drop(event: CdkDragDrop<any[]>) {
if (event.previousContainer === event.container) {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
} else {
transferArrayItem(event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex);
}
}
}
I want to display the visited countries in the dropped list (where have you been)
How to solve this in my Ionic App
https://mytopcountries.web.app/tabs/home
You can use this syntax to set the index value into an attribute of the HTML Element:
Or you can use a syntax like: