私はこのような配列構造を持っています。オートコンプリートに必要なAngularJS multipleスコープ
[
{
"id": "1",
"name": "John",
"city": "NY"
},
{
"id": "2",
"name": "Gerold",
"city": "LA"
},
{
"id": "3",
"name": "Stuart",
"city": "Boston"
}
]
私はオートコンプリートの検索については、以下のような$スコープを必要としています。
$scope.name=["john","Gerold","Stuart"];
$scope.city=["NY","LA","Boston"];
誰でも、anglejsコントローラを使用してこれを得ることができます。 ありがとうございます。
を名前と都市の配列にユニークなものを使用するようにフィルタを行うことができます$scope.YourBigArray = [{
"id": "1",
"name": "John",
"city": "NY"
}, {
"id": "2",
"name": "Gerold",
"city": "LA"
}, {
"id": "3",
"name": "Stuart",
"city": "Boston"
}];
$scope.names = $scope.YourBigArray.map(function(object) {
return object.name;
});
$scope.cities = $scope.YourBigArray.map(function(object) {
return object.city;
});
おかげで...!私はこれを試してみる.. .. !! –