我对angular有点陌生,最近我有一段代码将对象数组推入新数组。
// THE NEXT TWO LINES CHANGED
ServerCallStreamObserver scso = (ServerCallStreamObserver) responseObserver;
while(!scso.isCancelled()){
if(changeFeedResponse!=null && !changeFeedResponse.getFinalize()){
responseObserver.onNext(changeFeedResponse);
changeFeedResponse = processData(responseObserver, changeFeedResponse.getToDate(), changeFeedResponse.getPageNo());
}else{
break;
}
}
此输出如下:
mainArr.Survey.forEach(item => {
newArray.push({
list: item.data.map((option: any) => {
const target = this.dataArray.find(x => x.name === item.name && option == x.value);
return {
[option]: target ? target.count : 0
}
})
});
});
有没有一种方法可以代替计数从其他对象值(最高到最低)返回其等级?这样吗?
"list": [
{
"1": "37"
},
{
"2": "45"
},
{
"3": "12"
},
{
"4": "21"
},
{
"5": "21"
}
],