Hi Divakar,
Thanks for contacting Syncfusion Support.
We have checked with your reported query on EJ Angular CheckBox to get the state of checkbox.
You can get the Checkbox state in the following ways.
1. Using checkbox 'checked' API
2. Using checkbox isChecked Method
3. Using args.isChecked argument in change event
We have prepared a sample to meet your requirement. Please download the sample from the below link.
In this sample, we have created an instance of EJ CheckBox and accessed the checkstate API of checkbox in ngAfterViewInit() method. Also, the Checkstate can be accessed via change event of Checkbox in run time as highlighted below.
[checkbox.component.html]
|
<ej-checkbox id="Checkbox1" #Checkbox1 [(checked)]="checked" size="small" text="Music" (ejchange)="onChange($event)" ></ej-checkbox>
|
[checkbox.component.ts]
|
onChange(args) {
if (args.isChecked) {
alert("checkbox has been checked");
} else {
alert("checkbox has been unchecked");
}
}
ngAfterViewInit() {
if (this.checkBoxInstance.widget.element.ejCheckBox('checked')) {
alert("checkbox has been checked");
} else {
alert("checkbox has been unchecked");
}
}
|
Also, check out the following links to explore further about Checkbox control.
Please, let us know if you need any further assistance.
Regards,
Deepa L.