Accessing a checkbox value on click in angular 2

Discussão em 'Angular' iniciado por rematnarab, Novembro 11, 2024.

  1. rematnarab

    rematnarab Guest

    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);
    }

    Continue reading...

Compartilhe esta Página