Reputation: 601
Any Idea in Angular 5 where I have the checkbox in *ngFor loop so I want to know how this is getting the change in check and uncheck for the particular checkbox in *ngFor.
I have some code as below
<tr *ngFor="let addon of group?.item_addons; let i = index;">
<td>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox"
(change)="onselectAddon(addon,$event,group,i)">
<span class="form-check-sign"></span>
{{addon.addons_name}}
</label>
<span class="float-right">+ {{addon.addons_price}}</span>
</div>
</td>
</tr>
I want to get selected and unselected value from particular checkbox.
Upvotes: 0
Views: 1415
Reputation: 6263
you can simply add to your input the following:
[checked]="someExpression"
if you prefer, you could call a function where you pass the current addon like
[checked]="isChecked(addon)"
Upvotes: 1