Angular2 is there a way to use a two way binding with a checkbox?


I want to use a two way binding for a checkbox, but if I use the [(ngModel)] it is showing true or false instead of the value of the checked item. Does anybody know how this is done?

If i want to use a two way binding and set it to “expression.value” in my case how do i do that:

<input type="checkbox" type="checkbox"/>&nbsp;Option 1</a></li>

I would like to bind the value of the checkbox in this case: Option 1 into the expression class.


This is a known issue

There are different workarounds like using instead of the value from the model.

You can use

<input type="checkbox"  
    (change)="expression && expression.Option1=$ ? true : undefiend"
<input type="checkbox"  
    (change)="expression && expression.Option2=$ ? true : undefiend"

Plunker example

Answered By – Günter Zöchbauer

Answer Checked By – Dawn Plyler (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.