I am trying to make a select component update itself after adding an option but I can't. Here is my code:
<script> const options = ['first_option'] const addEventSignal = () => { const option = prompt('Please enter new option', '') if (option) { options.push(option) } } const doSomething = event => { console.log(event) }</script><style></style><div><select bind:value={options} on:change={doSomething}> {#if options} {#each options as option}<option value={option}>{option}</option> {/each} {/if}</select><button type="button" on:click={addEventSignal}>Add Signal</button></div>
If I reload the component it shows the new option but I would like to have the new option in the select list as soon as the input dialog is gone.