I am unable to read checkbox value in ionic 2 i tried following code
<div class="form-group">
<label ></label>
<div *ngFor="let mydata of activity" >
<label>
<input type="checkbox"
name="activity"
value="{{mydata.activity_id}}"
[checked]="activity.includes(mydata)"
(change)="changeSchedules(mydata)"
/>
{{mydata.activity_name}}
</label>
</div>
</div>
script file
this.subscriptionForm = new FormGroup({
activity: new FormArray(this.subscription.schedules.map(schedule => new FormControl(schedule)), Validators.minLength(1))
});
changeSchedules(mydata: any) {
var currentScheduleControls: FormArray = this.subscriptionForm.get('activity') as FormArray;
var index = currentScheduleControls.value.indexOf(mydata);
if(index > -1)
{currentScheduleControls.removeAt(index) }
else
{
currentScheduleControls.push(new FormControl(mydata));
}
}
i searche so many things but i did not get proper solution can somebody help to figure out this
Please following i think it will help you
your .ts file code
and your html code
updateOptions() you will get all selected check box value
Try this code of example