【发布时间】:2016-07-05 18:12:55
【问题描述】:
我有一个 HTML <select> 标签:
Document type <select class="form-control" name="document_type" ng-model="document_type"
ng-options="opt as opt.label for opt in options" required>
我在我的模型范围内保存了一个options 变量:
$scope.options = [{
label : '',
value : ''
}, {
label : "ID card",
value : "ID card"
}, {
label : 'Passport',
value : 'Passport'
}, {
label : 'Driving license',
value : 'Driving license'
} ];
这样我就有了以下字段:
我的目标是使用$scope 设置document_type“变量”:
$scope.document_type = "Passport"
但它不起作用,<select> 字段保持空白。
【问题讨论】:
-
文档类型的数量是否已知且有限?
-
是的。我的图片中只有三个选项。
-
查看我刚刚发布的解决方案。
标签: html angularjs angularjs-scope