我有一个包含员工列表的选择框。当我选择一个时,它将字符串值发送到控制器。我需要传递所选名称的Id,而不是名称值本身。 plunker
<label>CustomerPM:</label>
<select style="width: 150px" ng-options="customer.CustomerEmployeeFirstName + ' ' + customer.CustomerEmployeeLastName as customer.CustomerEmployeeFirstName + ' ' + customer.CustomerEmployeeLastName for customer in customerEmployeeArray | filter:{CustomerEmployeeRole : 'PM', CustomerId : currentItem.CustomerId}" ng-model="currentItem.CustomerEmployeePMId">
<option value="" selected="selected">Select</option>
</select><br />
{{currentItem.CustomerEmployeePMId}}<br />
<label>CustomerSuper:</label>
<select style="width: 150px" ng-options="customer.CustomerEmployeeFirstName + ' ' + customer.CustomerEmployeeLastName as customer.CustomerEmployeeFirstName + ' ' + customer.CustomerEmployeeLastName for customer in customerEmployeeArray | filter:{CustomerEmployeeRole : 'Super', CustomerId : currentItem.CustomerId} " ng-model="currentItem.CustomerEmployeeSuperId">
<option value="" selected="selected">Select</option>
</select><br />
{{currentItem.CustomerEmployeeSuperId}}<br/>
答案 0 :(得分:1)
删除ng-options
属性的第一部分customer.CustomerEmployeeFirstName + ' ' + customer.CustomerEmployeeLastName as
- 并将其替换为customer.CustomerEmployeeId as
来自the docs:
select
:此表达式的结果将绑定到父元素的模型。如果未指定,则select expression将默认为value。