dimanche 4 septembre 2016

using ng-true-value and ng-false-value in angualr2-material checkbox

I am using anular2-material/checkbox in my form. I wanna bind it to a database field by ngModel attribute. and if the database field is 10 , my md-checkbox should be checked ,otherwise,it is unchecked.

 <md-checkbox [checked]="item[valueKey] == '10'"
  [(ngModel)]=selected.active
       ng-true-value ="'10'"  ng-false-value="'20'" [disabled]="disabled"  
       align="start" (change)="onChange($event,item,valueKey)"
        (onInputFocus)="onFocus()">
        
</md-checkbox>

what is your recommendation? By the now, checkbox is checked by both 10 and 20 values.

thanks




Aucun commentaire:

Enregistrer un commentaire