我有一个JSON文件,如下所示,我希望使用id“37”,“46”或“47”按desc排序。但我不知道怎么做,因为我正在使用“Object.keys(this.incident)”访问这些数据,我用这种方式订阅数据:
`ngOnInit(): void {
Observable.timer(0,60000).flatMap(() => this.http.get<any>(this.dataUrl))
.subscribe(data => { this.incidents = data, console.log(data)});
}`
我想通过使用类似于以下内容的方式对数据进行排序:
<div *ngFor="let incident of incidents | orderby">
[
{"37":
[{"NINJAOPS_MASTER":[]},
{"NINJAOPS_EVENT_COLLECTION":[]},
{"NINJAOPS_DIAGNOSIS":[]},
{"NINJAOPS_DECISION":[]},
{"NINJAOPS_REMEDIATION_AI":[]}]},
{"46":
[{"NINJAOPS_MASTER":
[{"NINJAOPS_ID":"46",
"BABYLON_REF":"8547",
"EVENT_COLLECTION_STATUS":"1",
"DIAGNOSIS_START":"2018-05-02 16:09:59"}]},
{"NINJAOPS_EVENT_COLLECTION":
[{
"NINJAOPS_EC_ID":"43",
"NINJAOPS_REF":"46"}]},
{"NINJAOPS_DIAGNOSIS":
[{
"NINJAOPS_DIG_ID":"7",
"NINJAOPS_REF":"46",},
{
"NINJAOPS_DIG_ID":"5",
"NINJAOPS_REF":"46",
"BABYLON_REF":"4185",
"PERCENTAGE_MATCH":"91.845",
}]},
{"NINJAOPS_DECISION":
[{
"NINJAOPS_DEC_ID":"3",
"NINJAOPS_REF":"46",
"BABYLON_REF":"8439",
"DECISION_START":"2014-06-25 22:35:00",
"DECISION_END":"2014-06-25 22:54:00",
"DECISION_STATUS":"1"},
{
"NINJAOPS_DEC_ID":"2",
"NINJAOPS_REF":"46",
"BABYLON_REF":"8440",
"DECISION_START":"2014-06-25 22:34:00",
"DECISION_END":"2014-06-25 22:34:05",
"DECISION_STATUS":"2"
}]},
{"NINJAOPS_REMEDIATION_AI":
[{
"NINJAOPS_REMEDI_AI_ID":"2",
"NINJAOPS_REF":"46",
"BABYLON_REF":"8440",
"PERCENTAGE_MATCH":"75.000"}]}
]},
{"47":
[{"NINJAOPS_MASTER":
[{
"NINJAOPS_ID":"47",
"BABYLON_REF":"8548",
"EVENT_COLLECTION_STATUS":"1"
}]},
{"NINJAOPS_EVENT_COLLECTION":
[{
"NINJAOPS_EC_ID":"39",
"NINJAOPS_REF":"47",
}]},
{"NINJAOPS_DIAGNOSIS":
[{
"NINJAOPS_DIG_ID":"24",
"NINJAOPS_REF":"47",
"BABYLON_REF":"4077",
"PERCENTAGE_MATCH":"89.185",
},
{
"NINJAOPS_DIG_ID":"26",
"NINJAOPS_REF":"47",
"BABYLON_REF":"4079",
"PERCENTAGE_MATCH":"89.185"
},
{
"NINJAOPS_DIG_ID":"23",
"NINJAOPS_REF":"47",
"BABYLON_REF":"4186",
"PERCENTAGE_MATCH":"89.185",
},
{
"NINJAOPS_DIG_ID":"25",
"NINJAOPS_REF":"47",
"BABYLON_REF":"4187",
"PERCENTAGE_MATCH":"89.185",
}]},
{"NINJAOPS_DECISION":[]},
{"NINJAOPS_REMEDIATION_AI":[]}]},
]
如果您对如何做到这一点有所了解,感谢您的帮助。
答案 0 :(得分:0)
*ngFor="let incident of incidents.slice().reverse()
这将反转您的数据数组。 祝你好运!!
答案 1 :(得分:0)