In my x.component.html file, I have a list of objects that are being displayed in Bootstrap cards like this:
<div *ngFor="let item of items | async">
<div class="row">
<div class="col-lg-6">
<div class="card card-accent-primary">
<div class="card-header">
{{item.name}}
<label class="switch switch-text switch-pill switch-primary float-right mb-0">
<input class="switch-input" type="checkbox" (change)="onSwitchItem($event)">
<span class="switch-label"></span>
<span class="switch-handle"></span>
</label>
</div>
<div class="card-body"></div>
</div>
</div>
</div>
</div>
I'm trying to figure out how to access the selected items in my x.component.ts file. Is there a way to directly get the item object without using indexes?
As of now, I am assigning an index to each item using angular property binding [id]="item.index"
, and then accessing the items array based on the index.