Below is the code:
HTML
<form ng-submit="fun()">
<select ng-model="a" ng-options="table.id as table.name for table in tables></select>
<input type="text" ng-model="b">hello</input>
<input type="submit">Ok</input>
</form>
JS
$scope.tables = [{"id":1, "name":"x"},{"id":2, "name":"y"},{"id":3, "name":"z"}];
//This is dummy data, tables is actually coming from another custom API
$scope.fun = function(){
console.log($scope.a);
console.log($scope.b);
}
This is the output:
undefined
hello
When I checked the source code, the options getting appended to my select look like this:
<option label="x" value="undefined:undefined"></option>
How can I get the selected option in the controller on ng-submit?