mercredi 25 avril 2018

angular 5 reactive form checkbox sends object

In a reactive form, I need a checked box to send a typed object to the Typescript file and not just a string or a number. When I try using value= I get [object Object]. Is it possible to retrieve the correct object? Here is my template using Material Design:

<mat-selection-list formControlName="weapons">
<mat-list-option *ngFor="let weapon of selectedUnite.weapons" value=""></mat-list-option>
</mat-selection-list>

and the Typescript formGroup declaration:

this.uniteFormGroup = this._fb.group({
id: unite['id'],
name: unite['unite'],
size: unite['size'],
weapons: '',
staff: ''
});

Thanks a lot for your precious help!




Aucun commentaire:

Enregistrer un commentaire