【发布时间】:2015-11-21 07:31:41
【问题描述】:
我在 php 中创建我的数据库数组并使用 json_encode 发送它
这是数组的var_dump
array (size=2)
'latestDate' => string '2015-08-27 07:30:34'
'rcList' =>
array (size=3)
'0' =>
array (size=4)
'name' => string 'somesite'
'url' => string 'http://www.somesite/rss'
'overrideurl' => string 'http://www.somesite/latest'
'site' => string 'http://somesite/'
'1' =>
array
'name' => string 'somesite1'
'url' => string 'http://somesite1/rss'
'overrideurl' => null
'site' => string 'http://somesite1.in/'
'2' =>
array (size=4)
'name' => string 'somesite3'
'url' => string 'http://somesite3/rss'
'overrideurl' => null
'site' => string 'http://somesite3/'
我得到的数据没问题,我可以使用 ng-repeat 显示它。
但是我无法对其进行排序
<div ng-repeat="item in List | orderBy:item.name" ui-sref="tabs.feed({ rcData:rc})">
<b>{{item.name|uppercase}}</b><br>
</div>
我知道 ng-repeat 只适用于数组,但我从 php 得到的是 json,所以我如何将它转换为数组以便我可以对其进行排序?
JSON 数据是这样的:
{
"latestDate": "2015-08-27 07:30:34",
"rcList": [
{
"name": "somesite",
"url": "http://www.somesite/rss",
"overrideurl": "http://www.somesite/latest",
"site": "http://somesite/"
},
{
"name": "somesite1",
"url": "http://somesite1/rss",
"overrideurl": "",
"site": "http://somesite1.in/"
},
{
"name": "somesite3",
"url": "http://somesite3/rss",
"overrideurl": null,
"site": "http://somesite3/"
}
]
}
这是一个好的数据结构吗..如果不是我应该使用什么类型或结构
【问题讨论】:
标签: javascript php json angularjs