I'm trying to bind values to dropdown list, my data is an Object array but can't find a way to bind the id of the selection to the dropdown value.
Here is my code and fiddle
var app = angular.module('myApp', []);
function Ctrl($scope) {
$scope.optionSource = [{
"name" : "First Cost",
"id" : "1"
}, {
"name" : "Second",
"id" : "3"
}, {
"name" : "Third",
"id" : "2"
}, {
"name" : "Sone",
"id" : "5"
}, {
"name" : "List CC",
"id" : "4"
}];
$scope.value = [2,4];
}
html
<select multiple="multiple" ng-model="value"
ng-options="option.name for option in optionSource">
</select>
I want the id to be the value.
thanks