Basically I do not know how to handle this topic from an *ngFor
where there is checkbox. I would normally know how to do it with a [(ngModel)]
, but I do not know how to do it with reactive forms. I want to associate my checkbox according to what I have in the variable "aUsers" and mark the elements that I have in the "check" attribute. what should I do?
this.ValidacionReunion = new FormGroup({
observaciones:new FormControl(null, []),
arrayElements: new FormControl.array([]) //this is the name of my checkboxlist
});
aUsers:any=
[
{
"name":"xds",
"userusuario":2,
"check":true
},
{
"name":"xdsx",
"iduser":2,
"check":false
}
]
. . .
<!-- obviously this is inside:<form [formGroup] = "ValidationReunion"> -->
<li class="list-group-item waves-light" *ngFor="let user of aUsers" >
<input type="checkbox" formControlName="user.check">
</li>
Aucun commentaire:
Enregistrer un commentaire