I have searched Google and can't find anything on this.(我已经搜索过Google,但找不到任何东西。)
I have this code.(我有这个代码。)
<select ng-model="somethingHere"
ng-options="option.value as option.name for option in options"
></select>
With some data like this(有了这样的数据)
options = [{
name: 'Something Cool',
value: 'something-cool-value'
}, {
name: 'Something Else',
value: 'something-else-value'
}];
And the output is something like this.(输出是这样的。)
<select ng-model="somethingHere"
ng-options="option.value as option.name for option in options"
class="ng-pristine ng-valid">
<option value="?" selected="selected"></option>
<option value="0">Something Cool</option>
<option value="1">Something Else</option>
</select>
How is it possible to set the first option in the data as the default value so you would get a result like this.(如何将数据中的第一个选项设置为默认值,这样您将得到这样的结果。)
<select ng-model="somethingHere" ....>
<option value="0" selected="selected">Something Cool</option>
<option value="1">Something Else</option>
</select>
ask by iConnor translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…