这是我的下拉列表
<select class="form-control" data-ng-options="obj.text for obj in options track by obj.value" data-ng-model="submission.issue" ng-init="submission.issue = options[0]" required></select>
这是填充我的下拉菜单,但是当我查看“submission.issue”的值时,我没有看到select中的选项项的值如预期,而是像
"Query {"text":"Select your query","value":""} "
默认情况下,我只想将submission.issue默认项目作为列表中第一个值为“”的项目。
以下是我填充列表的方法
$scope.options = [
{ text: $scope.select_default, value: "" },
{ text: $scope.select_issue_1, value: $scope.select_issue_1 },
{ text: $scope.select_issue_2, value: $scope.select_issue_2 },
{ text: $scope.select_issue_3, value: $scope.select_issue_3 },
{ text: $scope.select_issue_4, value: $scope.select_issue_4 },
{ text: $scope.select_issue_5, value: $scope.select_issue_5 }
];
答案 0 :(得分:0)
将ng-options表达式更改为如下所示:
"obj.value as obj.text for obj in options track by obj.value"
$ scope.submission.issue应该等于下拉列表中所选项目的值。