Chris Forever
Chris Forever

Reputation: 678

ng-select will always show up one empty option

My code is as below:

<select ng-model="timeModel" class="col-sm-1">
    <option>10:30</option>
    <option>15:30</option>
</select>

And the web page will be like this:

enter image description here

Is there anything incorrect?

Thanks.

Upvotes: 0

Views: 421

Answers (1)

GordyD
GordyD

Reputation: 5103

When working with a SELECT element if none of the options provided equal the value in ng-model then it will create a blank option to represent the current state of the model.

I have created a JSFiddle to demonstrate this behaviour.

It would help if you displayed the value of timeModel in your view to see what value this is set to. You could then inspect what the underlying value is and why it is not behaving as you intended it to.

Upvotes: 1

Related Questions