Change only one checkbox

Asked

Viewed 168 times

0

How do I change only the checkbox I’m clicking?

checked:boolean=false;
ck() {
    if(this.checked === false){
      this.checked=true;
    }else{
      this.checked=false;
    }
<ion-item>
  <ion-label  class="title" [class.title-service-check]="checked">item 01 <span class="box-service-price">R$ 80,00</span></ion-label>
  <ion-checkbox color="green" (click)="ck()"></ion-checkbox>      
</ion-item>
<ion-item>
  <ion-label class="title" [class.title-service-check]="checked">item 02 <span>R$ 80,00</span></ion-label>        
  <ion-checkbox color="green" (click)="ck()"></ion-checkbox>
</ion-item>

  • I do not use Ionic, I do not know if here has how to perform Ionic, but you have tried to put this inside ck() ?

1 answer

1

You need a variable checked with another clear name for each checkbox. You don’t need a function for that logic. You can do so:

<ion-checkbox color="green" (click)="checked=!checked"></ion-checkbox>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.