Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70804

Why is my value not binding in ion-checkbox?

$
0
0

Hi, I am using the ion-checkbox for the first time and I’m a little confused about the usage. What I am trying to achieve is to add the value I set through v-model to an array if the checkbox is checked so I can retrieve the values from the array. For the checkbox I have:

<ion-checkbox class="categoryCheckbox" value="Music" v-model="categories"></ion-checkbox>

And then I display the checked checkboxes as such:

<span>Checked categories: {{ categories }}</span>

Where categories is the array I want to populate with the values of the checked boxes.

However this results in the value of categories to be true or false, depending on whether or not the checkbox is checked, and doesn’t contain the value of “Music” as intended. I would think this is the checked property and not the value property. I don’t understand the usage of

 @update:modelValue="entry.isChecked = $event :modelValue="entry.isChecked">" 

that I see in the documentation.

I followed the Vue documentation for this type of input binding as I am confused about how it works using ion-checkbox. Any help is appreciated!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>