今天学习Angular.js遇到的问题,刚运行的下拉菜单第一个值为什么为空?
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<meta charset="utf-8">
<title>angular01</title>
<script src="js/angular.min.js"></script>
</head>
<body>
<div ng-controller="myCtrl">
<select ng-model="x" ng-init="x.name = '4'" ng-options="x.name for x in colors"></select>
<a href="">{{x.name}}</a>
</div>
<script type="text/javascript">
var app = angular.module("myApp",[]);
app.controller("myCtrl",["$scope",function ($scope) {
$scope.colors = [
{name:"1"},
{name:"2"},
{name:"3"}
]
}]);
</script>
</body>
</html>
初始默认数据,老杨出品