0

I develop some application using AngularJS (v1.5.8). For validation purposes, I need to submit both key and value from select input, I mean the selected option (key and value) in angular form.

<select id="someId" ng-model="someModel" name="someName">
<option ng-repeat="(key, value) in someDictionary" value="{{::key}}">{{::value}}</option>
</select>

Does anybody know how to achieve this? I don't want to override the submit method, I'd like to get the key and value in json in any kind of format.

Koteczeg
  • 161
  • 2
  • 16
  • It would be nice if that would be separate fields,I have already found this: http://stackoverflow.com/questions/11976303/sending-both-the-value-and-key-of-an-option-box-as-parameters which does not satisfy me at all – Koteczeg Sep 14 '16 at 08:23

2 Answers2

0

If you don't separate the key and the value you can provide them both to the model

<option ng-repeat="element in someDictionary" value="{{element}}">{{element.value}}</option>

I haven't tested it so it might need some adaptations.

taguenizy
  • 2,140
  • 1
  • 8
  • 26
0

You can try this -

 <select id="someId" ng-model="someModel" name="someName">
  <option ng-repeat="(key,value) in someDictionary" value="{{[key,value]}}">{{value}}</option>
 </select>
Disha
  • 822
  • 1
  • 10
  • 39