Dynamically create select options on the fly

Viewed 4539

I have 2 selects, one with data and other one empty. When first one is selected, I catch it using a switch. Now, depending on the value, I want to create option elements and put them inside empty select.

Let's say I have an array of values

var values = ['Hello', 'world', 'etc']

When selected

selected(event) {
  var name;
  switch (event.target.value) {
    case 'roth':
       // append values as options into select, using foreach
       // such as:
       // <option value="hello">Hello</option>
    ...
  }
}

This is select in my template:

<select class="form-control" :id="selection">
    <option selected="" disabled="" value="0"></option>
</select>
1 Answers
Related