# Determining if checkbox is checked

**URL:** <https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628>\
**Category:** ionic-v3\
**Created:** [October 30, 2016, 11:52am UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628 "2016-10-30T11:52:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ariang](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@ariang](https://forum.ionicframework.com/u/ariang)\
**Post date:** [October 30, 2016, 11:52am UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/1 "2016-10-30T11:52:41Z")

</div>

Hi there

How can I determine if a ion-checkbox is checked?

```
<ion-item *ngFor="let a of q.Answers">
   <ion-label>{{a.AnswerDescription}}</ion-label>
   <ion-checkbox (click)="addValue($event)" [(ngModel)]="a.checked"></ion-checkbox>
</ion-item>

```

the following return undefined

```
 addValue(e): void {
     var isChecked = e.currentTarget.checked;
     console.log(isChecked);//undefined

 }
```

---

<div class="post-metadata">

**Author:** ![prolland006](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/prolland006/32/104110_2.png) [@prolland006](https://forum.ionicframework.com/u/prolland006)\
**Post date:** [October 30, 2016, 6:57pm UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/2 "2016-10-30T18:57:32Z")

</div>

hi ariang, you should have the checked value in a.checked of your function. In addValue you q.Answers should have the .checked changed to the new value.

I tried this and it is working :

```
  <ion-item>
    <ion-label>AnswerDescription</ion-label>
    <ion-checkbox (click)="addValue($event)" [(ngModel)]="checked"></ion-checkbox>
   </ion-item>

 checked : boolean = true;
  addValue(e): void {
    var isChecked = e.currentTarget.checked;
    console.log(e.currentTarget);//undefined
    console.log(this.checked);//it is working !!!

  }
```

---

<div class="post-metadata">

**Author:** ![ariang](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@ariang](https://forum.ionicframework.com/u/ariang)\
**Post date:** [October 31, 2016, 6:43am UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/3 "2016-10-31T06:43:09Z")

</div>

Cool, thank you. My mind wasn’t working yesterday and eventually I managed to see the wood from the trees.

Silly me

---

<div class="post-metadata">

**Author:** ![miyaspm](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@miyaspm](https://forum.ionicframework.com/u/miyaspm)\
**Post date:** [February 9, 2017, 5:06am UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/4 "2017-02-09T05:06:34Z")

</div>

its working perfectly

---

<div class="post-metadata">

**Author:** ![leonardofmed](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@leonardofmed](https://forum.ionicframework.com/u/leonardofmed)\
**Post date:** [April 18, 2019, 1:15pm UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/5 "2019-04-18T13:15:54Z")

</div>

This help me a lot. I have made some changes, this don’t get the real checkbox state, but change the boolean variable and simulate it.

**Using Ionic v4**

**HTML**

```auto
<ion-item>
    <ion-label>AnswerDescription</ion-label>
    <ion-checkbox (click)="addValue($event)"></ion-checkbox>
</ion-item>

```

**TS**

```auto
checked : boolean = false;
	
addValue(): void {
  	this.checked = !this.checked;
  	console.log("checked: " + this.checked);//it is working !!!
	
}

```

* * *

**Edit - April, 22, 2019**

The method bellow get the real value (checked or not) from checkbox and display.

**TS**

```auto
addValue(e): void {
  	console.log(e.currentTarget.checked);	
}

```

**HTML**

```auto
<ion-item>
    	<ion-label>AnswerDescription</ion-label>
    	<ion-checkbox (ionChange)="addValue($event)"></ion-checkbox>
 </ion-item>

```

---

<div class="post-metadata">

**Author:** ![krunallathiya](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/krunallathiya/32/133532_2.png) [@krunallathiya](https://forum.ionicframework.com/u/krunallathiya)\
**Post date:** [August 17, 2020, 6:22pm UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/6 "2020-08-17T18:22:32Z")

</div>

Just use an NgModel.

```auto
<ion-checkbox checked="false" [(ngModel)]="yourVariable.checked"></ion-checkbox>

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 8:54pm UTC](https://forum.ionicframework.com/t/determining-if-checkbox-is-checked/68628/7 "2021-07-19T20:54:15Z")

</div>

Closed on July 19, 2021, 8:54pm UTC


