8

I try to make a simple select dropdown with AngularJS

this is my code:

<select class="span3" novalidate=""  data-ng-options="select p.name for p in create_options_array(item.values)">                                                </select>

create_options_array(item.values) is in this form:

[{"id":0,"name":"OG"},{"id":1,"name":"OS"},{"id":2,"name":"PG"},{"id":3,"name":"PS"}]

the select dropdown appears but it does not have any value on it to select, what I'm doing wrong?

akuzma
  • 1,592
  • 6
  • 22
  • 49
maki
  • 525
  • 1
  • 7
  • 27

1 Answers1

26

I believe you are missing an ngModel directive and you are invoking the ng-options directive in an incorrect way.

I made plunker here where it would work.

Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156
Florian
  • 3,366
  • 1
  • 29
  • 35
  • 4
    this was bugging me for ages! thanks for the help! it's a shame you *need* an ng-model though, I wasn't/am not ready to know where im going to save the data just yet so had to put a placeholder in :( – DrogoNevets Dec 16 '13 at 11:08
  • you could use a regular ` – Florian Dec 16 '13 at 13:56