0

以下代码将对 id 做选项名称。

<select ng-model="vm.ships" ng-change="vm.updateShip()"  data-ng-options="ship as ship._id for ship in vm.readyships">

问:我怎样才能把名字变成“ship ship.idis ready ( ship.to)”?

这甚至可能与ng-options有关吗?

想要的结果:

<option value="0" selected="selected" label="57e261">ship 57e261 is ready (sweden) </option>

更新:

变量ship.to可用

4

3 回答 3

1

您已经在data-ng-options. 为了获得完整的标签,您可以连接附加文本:

<select ng-model="vm.ships" ng-change="vm.updateShip()"  data-ng-options="ship as ('ship' + ship._id + ' is ready (' + ship.to + ')') for ship in vm.readyships">

除了文档之外,这个先前的答案总结了您拥有的不同选项ng-options

于 2016-10-13T14:51:06.053 回答
0

如果to是您的array.

ng-options="obj as obj.to for obj in results"
于 2016-10-13T14:40:07.690 回答
0

假设ship.to存在:

<select ng-model="vm.ships" ng-change="vm.updateShip()" data-ng-options="ship as ship._id + ' is ready (' + ship.to + ')' for ship in vm.readyships">
于 2016-10-13T14:51:39.817 回答