javascript - AngularJS 多维数组排序

标签 javascript php angularjs json multidimensional-array

我有一个多维数组,正在解析为 JSON,我想在 AngularJS 中“排序”。我收到此错误:错误:[orderBy:notarray]预期数组但收到:13

<div ng-repeat="x in thread track by x.Id | orderBy: x.Id">

这是我的 JSON:

{
  "13": {
    "Id": 16,
    "LINK_Id": 16,
    "Attachments": [
      {
        "AttachmentName": "Attachment.jpeg",
        "AttachmentLinkId": 6,
        "LinkType": "Thread",
        "ThreadId": 20
      },
      {
        "AttachmentName": "Attachment.txt",
        "AttachmentLinkId": 7,
        "LinkType": "Thread",
        "ThreadId": 20
      }
    ]
  },
  "16": {
    "Id": 16,
    "LINK_Id": 169
  },
  "19": {
  "Id": 19,
  "LINK_Id": 112

} }

如果有人能提供帮助,我们将不胜感激。

非常感谢,

最佳答案

使用 orderBy Go through this 时有一些限制和规则。 迭代对象的对象(充当关联数组或哈希) 这个标题就是您想要实现的目标。

关于javascript - AngularJS 多维数组排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42299018/

相关文章:

javascript - 代码学院 : Loops and Arrays 2, 12/14

javascript - 使用 module.exports 和回调函数导出对象

javascript - jTable插件: The dynamic table is not getting refreshed after adding a new row

php - 使用 PHP MySQL 显示特定 child ID 的 parent

javascript - 在 angular.js 中,我可以在 $eval() 之前过滤一些东西吗?

javascript - AngularJS - 允许计算输入可编辑

javascript - AngularJS : Why to check whether newValue is the same as oldValue in `$watch` listener?

javascript - 如何同步2个async.waterfalls

php - 使用 CKEditor setData 函数时管理报价

php - Zendframework/PgSQL fetchAll orderby