I've simplified my code down to this:
<form ng-submit="doStuff($('select').val())">
<select name="menu">
<option value="foo">bar</option>
</select>
</form>
When I submit the form, I want angular to pass <select>'s value is to the function doStuff(). Whats the best way to go about this?
You dont need to pass the dropdown's value to the submit handler.
It would be available as $scope.menu inside the doStuff method.
Also, you should use angular's ng-options to fill the options inside the dropdown:
<form ng-submit="doStuff()">
<select ng-model="menu" ng-options="item.name for item in items">
</select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With