S
S
Sergey2015-11-11 11:04:40
Angular
Sergey, 2015-11-11 11:04:40

What to use ng-options or ng-repeat?

There is data:
var words= {a: 1, b: 2, c: 3};
Is it possible to make a select through ng-options ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2015-11-11
@Sergamers

DEMO .

<select ng-options="k as v for (k, v) in words">
    <option value="">Choose word</option>
</select>

N
Nicholas, 2015-11-11
@healqq

If converted to an array:
Then you can write something like this:

ng-options="word as word.key for word in words track by word.value"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question