0

I am trying to load the drop down values from an array using angular js.

I see and can make it work when data (array is in this format);

items = [
    { id: 1, name: 'Foo' },
    { id: 2, name: 'Bar' } 

which can be loaded

<div ng-controller="ExampleCtrl">
    <select ng-model="selectedItem" 
            ng-options="item as item.name for item in items"></select>

</div>

However data I am receiving is in this format with no identifiers;

items = {["Moe", "Larry", "Curly"]}

How would i load the select with the names from my array?

1
  • Are you sure this is the right format of your data? Does it has curly braces before the square nes? Commented Aug 28, 2015 at 18:08

1 Answer 1

1

I think you'll be looking for item as item for item in items as silly as that looks haha.

So;

<div ng-controller="ExampleCtrl">
<select ng-model="selectedItem" 
        ng-options="item as item for item in items"></select>
</div> 

Hope that helps!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.