好的,所以我想把我的json数据整理成一个表:
{
"0": {
"1": {
"airdate": "2011-12-04",
"file_size": 368279154,
"location": "filepath",
"name": "episodename",
"quality": "Unknown",
"release_name": "",
"status": "Downloaded",
"subtitles": ""
}
},
"1": {
"1": {
"airdate": "2011-12-04",
"file_size": 368279154,
"location": "filepath",
"name": "episodename1",
"quality": "Unknown",
"release_name": "",
"status": "Downloaded",
"subtitles": ""
},
"2": {
"airdate": "2011-12-04",
"file_size": 368279154,
"location": "filepath",
"name": "episodename2",
"quality": "Unknown",
"release_name": "",
"status": "Downloaded",
"subtitles": ""
},
"14": {
"airdate": "2011-12-04",
"file_size": 368279154,
"location": "filepath",
"name": "episodename14",
"quality": "Unknown",
"release_name": "",
"status": "Downloaded",
"subtitles": ""
}
}
问题是我的角度ng-repeat按字母顺序排列ex 1,14,2 ...我似乎无法使用此对象来获取密钥并将其设置为对象的ID参数但是我认为这将是最好的选择。任何的意见都将会有帮助。我想请注意,我无法改变服务器端api。
答案 0 :(得分:0)
如果某些集合的顺序很重要,则应考虑使用数组。
如果坚持使用对象,那么就是创建一个数组来保持对象的键以便用于命令目的
原型
scope.obj = {"1":{}, "2":{}, "14":{}};
scope.objKeys = ['1', '2', '14'];
<div ng-repeat="key in objKeys">
{{obj[key]}}
</div>