使用ng-options
遍历{title: '', value: ''}
的对象以显示title
中的select list
并使用控制器中的value
,但我得到了完整的对象而不是vlaue。
这是视图代码:
<select class="form-control" ng-model="item.action" ng-options="option.title for option in options">
</select>
控制器代码:
$scope.options = [{
title: 'title one',
value: 'value one'
}, {
title: 'title two',
value: 'value two'
}];
$scope.item = {};
$scope.item.action= $scope.actio.value; // here am getting the obect title and value when i want to pull only the value
答案 0 :(得分:0)
根据https://docs.angularjs.org/api/ng/directive/ngOptions#-select-as-and-track-by-,您可以尝试:
<select class="form-control" ng-model="item.action" ng-options="option.value as option.title for option in options">
</select>