我正在控制器上使用此数组:
var vm = this;
vm.documentGenerationEnum= [
{id:0, name: 'Manual'},
{id:1, name: 'Automatic'}
];
我正在html上使用它
<select ng-model="vm.editable.DocumentGeneration"
ng-options="option.id as option.name for option in vm.documentGenerationEnum"
class="product-field-input dropdown">
</select>
尽管我收到的空下拉列表对我来说没有任何意义。我非常确定代码编写正确,因为这对我来说不是一个新话题。但是我不确定还有哪些其他因素可能导致这种情况发生,我还可以考虑其他哪些因素?
答案 0 :(得分:1)
在此示例中工作正常:
angular.module("app",[])
.controller("ctrl", function() {
var vm = this;
vm.editable = {};
vm.documentGenerationEnum= [
{id:0, name: 'Manual'},
{id:1, name: 'Automatic'}
];
})
<script src="//unpkg.com/angular/angular.js"></script>
<body ng-app="app" ng-controller="ctrl as vm">
<select ng-model="vm.editable.DocumentGeneration"
ng-options="option.id as option.name for option in vm.documentGenerationEnum"
class="product-field-input dropdown">
</select>
<br>Selection={{vm.editable.DocumentGeneration}}
</body>