In the code shown below,
I am iterating over deliveryMethods which are displayed in the view as radio buttons. I intend to have the first radio button pre-selected.
I applied the following attribute:
[checked]="ndx==0"
where ndx is the index of each iteration. But none of the radio button is checked.
How do I dynamically pre-select the first radio button?
<div *ngFor="let dm of deliveryMethods; let ndx=index">
<label class="form-check-label">
<input class="form-check-input f-s-1pt2" type="radio"
name="dm.name"
value="{{dm.name}}"
[(ngModel)]="item.item.deliveryMethod"
(change)="filterProducts(item)"
[checked]="ndx==0"
class="radio-dimension">
{{dm.label}}
</label>
</div>
[value] = "dm.name"to use property binding and then setitem.item.deliveryMethodas the same value in typescript to have the radio button pre selected.