Reputation: 6144
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.
Upvotes: 0
Views: 59
Reputation: 3774
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.
Upvotes: 2