I have a single input checkbox, from which I need pass the checkbox status true or false to backend. I can see the value change from console when check and uncheck the box. however, failed to get it.
<div class="d-flex justify-content-center">
<input type="checkbox" class="checkbox" id="color" [checked]="picture.isColor" #color="ngModel" [ngModel]="checked" (click)="setColor(picture.id, color)"> <span style="color: #008CBE;">set color</span>
</div>
setColor(id, color) {
console.log(id);
console.log(color.control);
console.log(color.value);
}
console results: the picture id is as expected. The console does contains the value as in below screenshot. however, I got undefined when try to log it as color.value.
Can anyone please help to get the value of the value, i.e., true?
Can anyone help to get the value of the value, i.e., true? What I got is undefined, why?
Aucun commentaire:
Enregistrer un commentaire