0

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.

Chris Forever
  • 678
  • 1
  • 5
  • 18
  • 2
    What is the value of timeModel? Does it equal either of the options you have provided? If it does not then it will equal a blank option. – GordyD Dec 19 '14 at 12:52
  • 1
    possible duplicate of [Why does angularjs include an empty option in select](http://stackoverflow.com/questions/12654631/why-does-angularjs-include-an-empty-option-in-select) – Evandro Silva Dec 19 '14 at 12:53
  • In js file, $scope.timeModel = "08:00". But seems that this timeMoedel did not work at all. – Chris Forever Dec 19 '14 at 12:55

1 Answers1

1

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.

GordyD
  • 5,063
  • 25
  • 29