JavaScript Multiple properties for visible ngOption value

I have an object similar to this:

$scope.division = [
  {
    name: "Tom",
    number: 1
  },
  {
    name: "Greg",
    number: 2
  }
];

Now in my HTML I'm using ngOption to display a drop down filled with values from the object.

<select data-ng-model="game.player1" data-ng-options="player.name for player in division">
  <option value="" disabled="true">Player 1</option>
</select>

This displays a drop down of names as expected. However, I want to actually display the name and number in the drop down. So for example if I hard-coded it:

<option>1 - Tom</option>
<option>2 - Greg</option>

I've tried various methods including stuff like this:

data-ng-options="player.number player.name for player in division"

But nothing seems to work.

Answer:1

You should be able to concatenate like so:

ng-options="(player.number + ' - ' + player.name) for player in division"
Answer:2

I wish to have a row of 3 images which will contain around 10 images per row. The image dimensions are 270x270px and should animate like you'd imagine clouds floating from right to left on the screen....

I wish to have a row of 3 images which will contain around 10 images per row. The image dimensions are 270x270px and should animate like you'd imagine clouds floating from right to left on the screen....

We are trying to test our controller with Karma, but Karma keeps complaining about an unknown provider: Error: [$injector:unpr] Unknown provider: userProvider <- user Are we injecting the user ...

We are trying to test our controller with Karma, but Karma keeps complaining about an unknown provider: Error: [$injector:unpr] Unknown provider: userProvider <- user Are we injecting the user ...

  1. karma error spawn unknown
  2. karma-server error spawn unknown

Arrays in a language like C have certain non-functional characteristics, like O(n) insertion and deletion. But C operates on the bare metal, allocating contiguous bytes of memory. In JavaScript, ...

Arrays in a language like C have certain non-functional characteristics, like O(n) insertion and deletion. But C operates on the bare metal, allocating contiguous bytes of memory. In JavaScript, ...

I'm trying to remove extra line breaks, so that texts are one after another, while preserving white spaces (used as indents) I have the following: report_text = report_text.split("\n").map($.trim)....

I'm trying to remove extra line breaks, so that texts are one after another, while preserving white spaces (used as indents) I have the following: report_text = report_text.split("\n").map($.trim)....