janosh / svelte-multiselect

Keyboard-friendly, accessible and highly customizable multi-select component
https://multiselect.janosh.dev
MIT License
274 stars 32 forks source link

adding value to options #1

Closed Avi-ADAM closed 3 years ago

janosh commented 3 years ago

You mean turn options into an array of objects like

const options = [
  { value: 42, label: 'Foo' },
  { value: 43, label: 'Bar' },
]

instead of an array of literals (i.e. strings or ints) like const options = ['Foo', 'Bar']?

Avi-ADAM commented 3 years ago

how should i call it option={options.label} is not working and i get eather error of "Unexpected token "."" or get it as "object object" instead of the label string.

janosh commented 3 years ago

Could you share your full code here?

Avi-ADAM commented 3 years ago
Full code ```js
```
janosh commented 3 years ago

So that's what I was asking above. MultiSelect doesn't currently support passing options as an array of objects. In its current implementation, you'd have to get rid of the country values and pass in only the country names:

<MultiSelect bind:selected {namefil} {placeholder} options={country.map(c => c.label)} {required} />