我的html代码;
<!doctype html>
<html ng-app ng-controller="peopleController">
<head>
<script src="js/angular.min.js" type="text/javascript"></script>
<script>
function peopleController($scope){
$scope.people = [
{ name : "aa" , age : 14 },
{ name : "ss" , age : 11},
{ name : "dd" , age : 12},
{ name : "ff" , age : 16},
{ name : "gg" , age : 13}
];
$scope.keys=(function(obj){
var keys = [];
for(var key in obj){
console.log(obj);
if(obj.hasOwnProperty(key)){ keys.push(key);}
}
return keys;
})($scope.people[0]);
}
</script>
<title>aasss</title>
</head>
<body >
<select ng-model="aaa">
<option ng-repeat="x in keys" value="{{x}}">{{x}}</option>
</select>
</body>
</html>
为选择元素生成 html 部分;
<select ng-model="aaa" class="ng-pristine ng-valid">
<option value="? undefined:undefined ?"></option>
<!-- ngRepeat: x in keys -->
<option ng-repeat="x in keys" value="name" class="ng-scope ng-binding">name</option>
<option ng-repeat="x in keys" value="age" class="ng-scope ng-binding">age</option>
</select>
当我从选择元素中删除 ng-model="aaa" 属性时,问题不会出现。可能是什么问题呢?