我正在使用 Angular Material,md-select
并且我想创建一个空白选项,这样当您选择它时,您在选择中没有任何价值。如果我要求它,那么我希望这个选项在检查时返回 false。
这是一个演示:https ://plnkr.co/edit/FZ8xt5ZCRJY3fFMh3fFU?p=preview
<html>
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</ript>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.min.js" data-semver="1.2.19"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<form>
<select ng-model="selectedValue2" required >
<option ng-repeat="option in options['id'] | orderBy: 'id'" ng-value="option.value">{{option.name}}</option>
</select>
<button type="submit">Submit</button>
</form>
</body>
</html>
我的情况更复杂,所以我不想要解决方法,我只想在选择空白选项时让所需的工作正常。