0

The following code will do the option name to the id.

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

Q: How can i make the name something to be "ship ship.id is ready ( ship.to) " ?

is that even possible to do with ng-options?

wanted result:

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

UPDATE:

variable ship.to is avaliable

georgeawg
  • 48,608
  • 13
  • 72
  • 95
maria
  • 207
  • 5
  • 22
  • 56

3 Answers3

1

You are already doing what you want in the label portion of the data-ng-options. In order to get the full label you can concatenate on the additional text:

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

In addition to the documentation, this previous answer sums up the different options you have with ng-options.

Community
  • 1
  • 1
Lucas L
  • 131
  • 1
  • 8
0

Its possible, if the to is part of your array.

ng-options="obj as obj.to for obj in results"
Thalaivar
  • 23,282
  • 5
  • 60
  • 71
0

Assuming ship.to exists:

<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">
Aks1357
  • 1,062
  • 1
  • 9
  • 19