I'm working on an app and one of the pages requires the user to choose payment by credit/card or cash. I want to make it so that both check boxes cannot be checked at the same time (If one is checked the other is unchecked).
I have tried making an event with ionChange so that if one of them is checked the boolean value of the other checkboxes becomes false.
HTML
<ion-item>
<ion-label>Credit/Debit Card (N/A)</ion-label>
<ion-checkbox item-start [(ngModel)]='CC' (ionChange)="checked()"></ion-checkbox>
</ion-item>
<br/><br/>
<ion-item>
<ion-label>Cash</ion-label>
<ion-checkbox item-start [(ngModel)]='Cash' (ionChange)="checked()"></ion-checkbox>
</ion-item>
Typescript
Cash = false;
CC = false;
checked(){
if(this.Cash == true){
this.CC = false;
}
if(this.CC == true){
this.Cash = false
}
}
I expected this to work but it is still possible to check both boxes.