# Issues with setting ion-checkbox using arrays

**URL:** <https://forum.ionicframework.com/t/issues-with-setting-ion-checkbox-using-arrays/203443>\
**Category:** Ionic Angular\
**Created:** [January 24, 2021, 1:52pm UTC](https://forum.ionicframework.com/t/issues-with-setting-ion-checkbox-using-arrays/203443 "2021-01-24T13:52:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yellowkicks](https://avatars.discourse-cdn.com/v4/letter/y/b782af/32.png) [@yellowkicks](https://forum.ionicframework.com/u/yellowkicks)\
**Post date:** [January 24, 2021, 1:52pm UTC](https://forum.ionicframework.com/t/issues-with-setting-ion-checkbox-using-arrays/203443/1 "2021-01-24T13:52:16Z")

</div>

I have been trying to figure out the best way to set a series of `ion-checkbox`'s using an array that is fed into my app through an API.

Right now, my app receives some data that looks like this:

```auto
{
	"data": {
		"tags": [
			55, 46, 193, 1002
		]
	}
}

```

I am then using a series of `ion-checkbox`'s to display whether or not that tag is selected for a certain item, like this:

```auto
<ion-item lines="full">
   <ion-label position="fixed" class="ion-text-wrap">Blue</ion-label>
   <ion-checkbox slot="end" [(ngModel)]="item.tags"></ion-checkbox>
</ion-item>

```

I am having some confusion around how I can set the model for `item.tags` to be associated back to the array of data I am receiving from the data feed.

Is there a value field in the `ion-checkbox` I can set that would then allow the checkbox to appeared to be check with the `data.tags` array has the matching value?

---

<div class="post-metadata">

**Author:** ![yellowkicks](https://avatars.discourse-cdn.com/v4/letter/y/b782af/32.png) [@yellowkicks](https://forum.ionicframework.com/u/yellowkicks)\
**Post date:** [January 24, 2021, 3:02pm UTC](https://forum.ionicframework.com/t/issues-with-setting-ion-checkbox-using-arrays/203443/2 "2021-01-24T15:02:15Z")

</div>

After some additional testing/research, this may be a better approach:

```auto
<ion-item lines="full">
   <ion-label position="fixed" class="ion-text-wrap">Blue</ion-label>
   <ion-checkbox slot="end" [(ngModel)]="item.tags" [value]="55" [checked]="item.tags.indexOf(55) > 0"></ion-checkbox>
</ion-item>

```

I will see if this gets me any closer.

---

<div class="post-metadata">

**Author:** ![yellowkicks](https://avatars.discourse-cdn.com/v4/letter/y/b782af/32.png) [@yellowkicks](https://forum.ionicframework.com/u/yellowkicks)\
**Post date:** [January 24, 2021, 4:35pm UTC](https://forum.ionicframework.com/t/issues-with-setting-ion-checkbox-using-arrays/203443/3 "2021-01-24T16:35:56Z")

</div>

Now, it seems that I am incorrectly using the `indexOf` function, as I am getting the item.tags.indexOf is not a function error.
