I am trying to use Angular2 syntax to create switches from an enumeration definition and bind a value to a property that has the type of this enumeration.
My html contains:
<div class="from_elem"> <label>Motif</label><br> <div *ngFor="let choice of motifChoices"> <input type="radio" name="motif" [(ngModel)]="choice.value"/>{{choice.motif}}<br> </div> </div>
In my @Component, I declared a set of options and values:
private motifChoices: any[] = [];
And in the constructor of my @Component, I filled in the following options:
constructor( private interService: InterventionService ) { this.motifChoices = Object.keys(MotifIntervention).filter( key => isNaN( Number( key ))) .map( key => { return { motif: key, value: false } }); }
The radio buttons are displayed correctly, now I'm trying to bind the value selected to the property. But when I click one of the buttons, the value.value is undefined.
angular button binding radio two-way
Anthony Brenelière Sep 08 '16 at 13:12 2016-09-08 13:12
source share