AngularJS select set default value

AngularJS select set default value


When using Angular, when using the select tag, you will encounter binding data to specify the default display value, which can be achieved like this
<!DOCTYPE html>
<html ng-app="noteApp" ng-controller="noteCtrl">
<head>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../plugins/angular.min.js"></script>

</head>
<body ng-app="noteApp" ng-controller="noteCtrl">
	<select ng-options="act.id as act.name for act in typeList"
		ng-model="ZNoteVo.type"></select>

</body>
<script type="text/javascript">
	angular.module("noteApp", []).controller("noteCtrl", function($scope) {
		$scope.typeList = [ {
			id : '01',
			name : "task"
		}, {
			id : '02',
			name : "log"
		}, {
			id : '03',
			name : "meeting"
		}, {
			id : '04',
			name : "learning"
		}, {
			id : '05',
			name : "Summary"
		}, {
			id : '99',
			name : "other"
		} ];
		$scope.ZNoteVo={};
		$scope.ZNoteVo.type = "03";
	});
</script>
</html>

When we select the type as 03, the default is conference



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326606871&siteId=291194637