我想摆脱选择中生成的空选项。
<option value="?" selected="selected"></option>
我还想做的是不自动设置第一个元素。基本上,一旦取消选中选择,该值应为空,但是一旦用户单击选择,他们将无法在其中看到该空选项。如果未选择而未选择,则选择应保留为空。
所以我不想以这个结尾 http://jsfiddle.net/MTfRD/6518/
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.typeOptions = [
{ name: 'Feature', value: 'feature' },
{ name: 'Bug', value: 'bug' },
{ name: 'Enhancement', value: 'enhancement' }
];
$scope.form = {type : $scope.typeOptions[0].value};
}
<div ng-controller="MyCtrl">
<select ng-model='form.type' required
ng-options='option.value as option.name for option in typeOptions'>
</select>
</div>
我看过数十篇文章,提出了这个答案,但不能解决我的问题。
答案 0 :(得分:3)
您可以像这样简单地进行黑客入侵
<div ng-controller="MyCtrl">
<select ng-model='form.type' required ng-options='option.value as option.name for option in typeOptions'>
<option value="" style="display: none"></option>
</select>
</div>
演示
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.typeOptions = [
{ name: 'Feature', value: 'feature' },
{ name: 'Bug', value: 'bug' },
{ name: 'Enhancement', value: 'enhancement' }
];
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<select ng-model='form.type' required ng-options='option.value as option.name for option in typeOptions'>
<option value="" style="display: none"></option>
</select>
</div>
答案 1 :(得分:0)
尝试一下..类似占位符
SELECT * FROM student_register
WHERE s_name IN ('english','malayalam','hindi')