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 answers, , each answer have single radio button.

plnkr example

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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -