0

Here are my objects within array:

[
    {"name":"someName1","label":"someLabel1"},
    {"name":"someName2","label":"someLabel2"},
    {"name":"someName3":"label":"someLabel3"}
]

How could I form select option with ng-options?

This link unfortunately doesn't pop the solution in my head or I am blinded by the complexity of my code, since this select field should be inside ng-repeat.

Imagine, all in ng-repeat:

someInput, someInput, select option (above case), somethingMore

I have no idea how to proper code and connect models in this situation.

Thank you in advance.

1 Answer 1

2

you can just do:

<select ng-options="item.name as item.label for item in myArray">

item.name is the value that will be matched/stored in the provided ng-model and item.label is the text that will be displayed to the user.

Here is plnk along with an ng-repeat usage example.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.