How to relating Checkbox enabling to Toggled button's status in ionic2?


#1

In this code I want to enable on select of check boxes and each selected check box return a value to identify which check box is selected and toggled button enable this checkbox:


<ion-content padding>
<ion-item>
  <ion-label> I have Licence </ion-label>
  <ion-toggle  checked="false"></ion-toggle>
</ion-item>

<ion-item>
  <ion-label> Daily A - from 8:00 </ion-label>
  <ion-checkbox color="dark" checked="true"></ion-checkbox>
</ion-item>

<ion-item>
  <ion-label>Daily B- from 10:00</ion-label>
  <ion-checkbox color="dark" checked="false"></ion-checkbox>
</ion-item>
<ion-item>
  <ion-label>Daily C - from 14:00 </ion-label>
  <ion-checkbox color="dark" checked="false"></ion-checkbox>
</ion-item>

<ion-item>
  <ion-label>Weekly - 7 days</ion-label>
  <ion-checkbox color="dark" checked="false"></ion-checkbox>
  <ion-label>Start Date</ion-label>
  <ion-datetime displayFormat="DD/MM/YYYY" pickerFormat="DDDD MMMM YYYY" [(ngModel)]="StartDate"></ion-datetime>

  <ion-label>End Date</ion-label>
  <ion-datetime displayFormat="DD/MM/YYYY" pickerFormat="DDDD MMMM YYYY" [(ngModel)]="EndDate"></ion-datetime>

</ion-item>
</ion-content>

#2

The way you say “which checkbox is selected”, and not “which checkboxes are selected” leads me to believe that they are all mutually exclusive: IOW, only one of them should be checked at a time. If that’s the case, use a radio group instead of checkboxes. Checkboxes are independent of one another.