我想用弹性搜索获得的聚合结果填充下拉列表。
我的回答一切都很好看
aggregations:{
status:{
buckets:{[
0:{key: "OPEN", doc_count: 57},
1:{key: "CLOSED", doc_count: 22}
]}
}
}
现在我想把“键”放在我的下拉变量中。 它应该看起来像这样
$scope.Options = ['','OPEN','CLOSED'];
我试过
$scope.Options = response.aggregations.status.buckets;
只给了我
[{key: "OPEN", doc_count: 57}, {key: "CLOSED", doc_count: 22}]
我不知道如何继续这一点。 提前谢谢
答案 0 :(得分:1)
试试这个:
$scope.Options = [''].concat(response.aggregations.status.buckets.map(b => b.key))
答案 1 :(得分:0)
试试这个
$scope.Options = response.aggregations.status.buckets.map(function(item){ return item.key});