这是我的对象
$scope.status = [{
"code": "CNA",
"name": "Consignee Not Available"
}, {
"code": "TBD",
"name": "To Be Delivered"
}, {
"code": "CRA",
"name": "Consignee Refused To Accept"
}, {
"code": "D",
"name": "Delivered"
} ]
我的HTML如下
<select ng-options="status.name for status in status" ng-model="awb.delivery_fail_reason">
<option value="">Please Select Status</option>
</select>
所以我想要的是
To be Delivered
时
我的模型变量
awb.delivery_fail_reason
应设置为TBD
awb.delivery_fail_reason
为TBD
时,它应自动将select设置为To Be Delivered
这可能吗 ? 答案 0 :(得分:1)
尝试
status.code as status.name for status in status
答案 1 :(得分:0)
在html中进行更改,如下所示
<select ng-model="awb.delivery_fail_reason">
<option value="">Please Select Status</option>
<option ng-repeat="s in status" value="{{s.code}}">{{s.name}}</option>
</select>
试试小提琴
http://jsfiddle.net/U3pVM/1489/