Is there a way to check if an array contains a certain value, using knockoutJS, within my HTML?
I have the following checkbox:
<td><input type="checkbox" name="group" data-bind="checked: $parent.name in groupList" /></td>
It would be nice if a certain statement inside my data-bind attribute ($parent.name in groupList) would work, but obviously it doesn't. With twig it's easy:
{% if myVar is in_array(array_keys(someOtherArray)) %}
But I cannot find a way to do this with Knockout JS. groupList contains an array with names and I would like to check if it contains a certain name. If it does, the checkbox needs to be checked, else not.
groupListthough. Knockout already provide anindexOfmethod that is unwrapping the value internally. So,groupList.indexOf(...)will do as well.