matth3o matth3o - 2 months ago 30
Dart Question

Dart Angular2 - bind component boolean with checkbox value

I'd like to know if there is a way to bind a regular checkbox in a template :

<input type="checkbox">


with a boolean in my component.

Bonus question : Otherwise is there a way to do

<input type="checkbox" {{mybool ? 'checked' : ''}}>


Thanks!

Answer
<input type="checkbox" [checked]="mybool">

or

<input type="checkbox" [(ngModel)]="mybool">