Hy, I need collect selected values through checkbox check's which are in ngFor. Below is the code.
<tr *ngFor="let item of items; let index = index;">
<td></td>
<td></td>
<td></td>
<td>
<input type="checkbox"
name="domain-"
[(ngModel)]="items[index].id"
>
</td>
</tr>
<button (click)="OnSelect()">Select</button>
In component, Im trying to access like this.
component.ts
items = [];
ngOnInIt() {
this.items = somepromise.then((items) => this.items );
}
OnSelect() {
console.log(this.items);
}
On Select, I see all values of items printed instead of selected check box values. Any thoughts ?
Aucun commentaire:
Enregistrer un commentaire