您可以将ng-options值链接在一起吗?

时间:2015-10-02 14:54:57

标签: angularjs ng-options

请原谅术语,但是您可以将ng-options值链接在一起吗?

这就是我所拥有的:

<select class="form-control" id="field_cusPro" 
       name="cusPro" ng-model="rentalAgreement.customerProfile" 
       ng-options="cusPro as cusPro.Name for cusPro in cuspros track by cusPro.id">
 <option value=""></option>
</select>

是否有ng-options="cusPro as cusPro.Name cusPro.id for cusPro in cuspros track by cusPro.id

这样的选择就像这样:

       Name1 ID1, Name2 ID2  etc...

而不仅仅是

       Name1, Name2, etc...

1 个答案:

答案 0 :(得分:1)

是的,你可以这样做:

<select class="form-control" id="field_cusPro" name="cusPro" ng-model="rentalAgreement.customerProfile" ng-options="cusPro as cusPro.Name+' ('+cusPro.id+')' for cusPro in cuspros track by cusPro.id">
 <option value=""></option>