我在其他帖子上读到过,但我想不出来。我有一个数组,$scope.items = [
{ID: '000001', Title: 'Chicago'},
{ID: '000002', Title: 'New York'},
{ID: '000003', Title: 'Washington'},];我想把它渲染为:<select>
<option value="000001">Chicago</option>
<option value="000002">New York</option>
<option value="000003">Washington</option></select>另外,我希望选择ID=000002的选项。我读过选择我试过了,但我想不出来。使用AngularJS的ng选项处理SELECT
3 回答
BIG阳
TA贡献1859条经验 获得超6个赞
items =[ { key:"AD",value:"Andorra" }, { key:"AI",value:"Anguilla" }, { key:"AO",value:"Angola" } ...etc..]
<select ng-model="countries" ng-options="item.key as item.value for item in items"></select>
<select ng-model="blah" ng-options="item.value for item in items track by item.key"></select>
ng-repeat
<select name="test"> <option ng-repeat="item in items" value="{{item.key}}">{{item.value}}</option></select>
添加回答
举报
0/150
提交
取消