Skylerdw
Skylerdw

Reputation: 357

ng-options - pass key instead of value

This is an ng-option select I'm using:

<select ng-model="languagePicker" ng-options="language for (key,value) in getLanguages()" ng-click="pickLanguage(0,languagePicker)"></select>

Passing languages2 in the chooseLanguage function makes it pass the value. I'd like to pass the key. How do I do it? Tried gooling it but no luck with how to do that in objects.

This is an example of what .getLanguages() returns:

{
"pl-PL":"Polish",
"en-GB":"English"
}

Upvotes: 0

Views: 107

Answers (1)

yBrodsky
yBrodsky

Reputation: 5041

ng-options="key as value for (key, value) in getLanguages()"

Upvotes: 3

Related Questions