selected-to-index
A converter that binds an index in a list to the selected item's value as a viewModel property.
selected-to-index(index, list)
When the getter is called, returns the item at the passed in index (which should be a can-compute from the provided list.
When the setter is called, takes the selected item and finds the index from the list and passes that to set the compute’s value.
<input value:bind="selected-to-index(index, people)" />
Parameters
- item
{can-compute}
:A compute whose value is an index from the list.
- list
{can-define/list/list|can-list|Array}
:A list used to find the
item
.
Use
The provided index
must be a can-compute so that its value can be set on user actions.