jeudi 5 octobre 2017

Accessing a checkbox value on click in angular 2

I have this checkbox which i want to see if it checked through ngModel binding. When i call console.log(activeCheckbox); i can see the ngmodel and its value property set to true in the console. But when i call console.log(activeCheckbox.value); right after or seperately, the value is undefined ?

Does anybody know what is happening here ?

    <input #activeCheckbox="ngModel" (click)="checkIfActive(activeCheckbox)"
 [disabled]="pageStatus==4" [ngModel]="premiumContententPackage.active"    
 name="premiumContententPackageActive" id="premiumContententPackageActive" 
    type="checkbox" >

checkIfActive(activeCheckbox){

   console.log(activeCheckbox);
   console.log(activeCheckbox.value);

}




Aucun commentaire:

Enregistrer un commentaire