表单里单/多选列表一般比较复杂,写个综合代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="mshApp" ng-controller="mshCtr">
<form name="myForm">
<select name="Select1" ng-model="data.singleSelect">
<option value="11">ASP.NET MVC5 高级编程</option>
<option value="12">Visual Studio 2015 高级编程 </option>
</select>
</form>
<tt>mySelect = {{data.singleSelect}}</tt><br/><hr>
<br/>
<select name="Select2" id="Select2" ng-model="data.multipleSelect" multiple>
<option value="11">ASP.NET MVC5 高级编程</option>
<option value="12">Visual Studio 2015 高级编程</option>
<option value="13">ASP.NET入门经典</option>
</select><br>
<tt>multipleSelect = {{data.multipleSelect}}</tt><br/>
</div>
<script>
angular.module('mshApp', [])
.controller('mshCtr', f1);
function f1($scope) {
$scope.data = {
singleSelect: null,
multipleSelec:[]
};
};
</script>
</body>
</html>