I am trying to record that the user has checked the checkbox, and am not sure where to start. this is using the ionic framework with vanilla JS.
I have the tag for a checkbox:
<ion-list>
<ion-checkbox id="Email-check">Email</ion-checkbox>
<ion-list>
A variable that is refering to the ID in the tag:
const emailCheckbox = this.querySelector('#Email-check');
And an empty function:
function storeemailCheck(){
}
2
Answers
As per the documentation there is a checked attribute on the ion-checkbox element, so you should be able to target that attribute using
emailCheckbox.checked
inside your function.Use ngModel Template Driven forms.
emailCheckbox will be true if user checks the checkbox and false if unchecked.If you need a change event you can call
ngModelChange