给定以下angularjs,它会创建一个下拉设置值和文本:
colors = { '1': 'red', '2': 'green','3':'blue' };
<select name='colors' ng-options="id as color for (id,color) in colors"></select>
将创建:
<select name='colors'>
<option value="1">red</option>
<option value="2">green</option>
<option value="3">blue</option>
</select>
如果我想为每个选项元素添加额外的属性,例如
,该怎么办?<select name='colors'>
<option class="red" value="1">red</option>
<option class="green" value="2">green</option>
<option class="blue" value="2">blue</option>
</select>