変更イベントが発生した後にフィルター処理されたデータを受け取る方法を理解するのに苦労しています。私のコード構造は次のようになります。アラートが発生しましたが、次に進むにはどうすればよいですか?
<html ng-app>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
</head>
<body ng-controller="List">
Search: <input ng-change="getData()" ng-model="query">
Search: <select ng-change="getData()" ng-model="query2">
<option></option>
<option>Berlin</option>
<option>Hamburg</option>
</select>
<div>
<ul class="names" >
<li ng-model="item" " ng-repeat="name in names | filter:query | filter:query2">
{{name.firstname}}, {{name.lastname}}, {{name.age}}, {{name.location}}
</li>
</ul>
</div>
<script type="text/javascript">
function List($scope) {
$scope.names = [
{"firstname": "Carl",
"lastname": "Luyk",
"age": 20,
"location":"Berlin"},
{"firstname": "Carl",
"lastname": "Moreen",
"age": 20,
"location":"Hamburg"},
{"firstname": "Tom",
"lastname": "Luyk",
"age": 25,
"location":"New York"},
{"firstname": "Caren",
"lastname": "Tilt",
"age": 20,
"location":"Paris"},
{"firstname": "Caren",
"lastname": "Orail",
"age": 30,
"location":"Hamburg"},
];
$scope.getData= function(){
//here I would like to get the data structured like $scope.names..is that possible?
alert('changed');
}
}
</script>
</body>
</html>