AngularJs and <select>: Default selected options are removed

前端 未结 6 1394
梦如初夏
梦如初夏 2021-02-13 16:05

I expect the following code to render a drop down list with the third option selected by default. However, when I bind the select with angularjs, the default selection disappear

6条回答
  •  长情又很酷
    2021-02-13 16:41

    By adding option with empty value to select and initializing selectedColors to empty string(ng-init="selectedColors=''"), we can see 'select Color' option on top instead of having first color to be selected defaultly:

    Selected Colors: {{selectedColors }}

    Try it on Fiddle http://jsfiddle.net/CodecPM/qxyckf7u/

提交回复
热议问题