0

这是我的对象

$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>

所以我想要的是

  1. 当用户选择状态时,To be Delivered 我的模型变量 awb.delivery_fail_reason应设置为TBD
  2. awb.delivery_fail_reason什么时候模型TBD应该自动将选择设置为To Be Delivered 这可能吗?
4

2 回答 2

1

尝试

status.code as status.name for status in status
于 2013-10-03T08:14:50.147 回答
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/

于 2013-10-03T08:27:12.890 回答