angular - Angular2 - How to bind radio buttons to boolean object properties -
i have pretty simple model looks this:
export class answer { constructor(public text: string, public iscorrect: boolean = false) { } }
and want bind radio button in such way if radio button selected, iscorrect
property true
, otherwise false
. proper way go this?
to clear, have array of answer
s, , each answer
have single radio button.
my template far looks this:
<label *ngfor="let answer of answers"> <input #rad type="radio" name="answer-{{questionindex}}" [(ngmodel)]="answer.iscorrect" [value]="rad.checked"> {{answer.text}} </label>
Comments
Post a Comment