我正在尝试将对象数组绑定到选择下拉列表,但我无法弄清楚如何使这项工作,有人可以建议如何使这项工作?
HTML:
<div ng-app ng-controller="DisplayCtrl">
<select ng-model="eventName" ng-options="name.event for name in eventNames">
<option value="">Select Event</option>
</select>
<p>Currently selected: {{eventName.description}} </p></div>
AngularJS:
function DisplayCtrl($scope) {
$scope.eventNames = [{
event: "Function A",
description: "Gaming"
}, {
event: "Function B",
description: "Basketball"
}, {
event: "Function C",
description: "Football"
}, {
event: "Function D",
description: "Dancing"
}];
$scope.eventName = $scope.eventNames[1].event;}