I am trying to check whether a value exists from one dataset to another dataset. Specifically, I want to utilize the id
property for this purpose.
I have been experimenting with handlebars.js, but the code below is not functioning properly.
Here is the spot_categories array:
{spot_categories:[{category:1},{category:2},{category:3},{category:4},{category:5},{category:6}]}
And here is the data array:
{data:[{spot_category_id:1},{spot_category_id:3}]}
Below is the vue.js code I have so far:
<!-- check if a variable exists -->
{{# var ok = false}}
<!-- iterate through categories -->
<li v-for="(category,j) in spot_categories">
<label>
<!-- iterate through data array -->
<template v-for="(val, l) in data">
<!-- check if spot_category_id matches category.id -->
<template v-if="val.spot_category_id == category.id">
{{ ok = true }}
</template>
</template>
<!-- if ok is true, display the value -->
<input :value="category.id" :checked="ok">
</label>
</li>
Can someone please assist me with this issue? Thank you!