When I submit a form with Angular selection, it sends the array index of the selected parameter, not its value. I need a string to send, because the server does not know about these indexes. How can i fix this?
From jsfiddle.net/2SuZG :
<form method="post" action="/my/post/endpoint"> <select name="resource" ng-options="r for r in ['a', 'b']" ng-model="selectedResource"></select> <button type="submit">Save</button> </form>
You can see from the console output in the script that the submitted form sends resource=0 , but I want resource='a' . (Note. In my violin, I serialize the form, but this is only to see what it will place. In my application, I actually send to the real endpoint.)
This is similar to this question , but the answer was “don't worry about the meaning”. But in my case, I submit the form, so I'm interested in value. I must be missing something very basic here. Thanks!
source share