Isuru Siriwardana
Isuru Siriwardana

Reputation: 545

Aurelia - Set default value in dropdown

I have a drop-down which is populated from a JavaScript array.

let a = [90, 95, 99];

When I bind this array in the HTML as follows, the initial value is set to 90.

<select>
    <option repeat.for="i of a">${i}</option>
</select>

But I need to show '95' as the default value. So how can I achieve this?

Upvotes: 2

Views: 1275

Answers (1)

Jesse
Jesse

Reputation: 3622

You can bind the value of the select to a certain value, which it will take as default.

let a = [90, 95, 99];
let selectedValue = 95;

Html:

<select value.bind="selectedValue">
    <option repeat.for="i of a">${i}</option>
</select>

Upvotes: 3

Related Questions