使用angularjs根据日期合并两个不同的数组列表

时间:2016-05-19 05:59:01

标签: jquery angularjs sorting

我有两个不同的数组列表,需要根据creationDate创建一个列表。

ChatMessage: -

[{
    "creationDate": "2016-05-18 09:21:39",
    "creationUser": "#12:41",
    "message": "sssss",
    "userEmail": "miaai.abc@aail.com",
    "userName": "Miaai",
    "userSurname": "dsith",
    "isRead": false,
    "dossierId": "#88:1"
}, {.. so on ..}]

文件清单: -

[{
    "name": "Hamlet.abook",
    "title": "Hamlet.abook",
    "inCompleteMetaData": true,
    "creationDate": "2016-05-17 11:25:23",
    "creationUser": "#12:41"
},{so on ...}]

OutPut将基于creationDate

[{
    "name": "Hamlet.abook",
    "title": "Hamlet.abook",
    "inCompleteMetaData": true,
    "creationDate": "2016-05-17 11:25:23",
    "creationUser": "#12:41"
},{
    "creationDate": "2016-05-18 09:21:39",
    "creationUser": "#12:41",
    "message": "sssss",
    "userEmail": "miaai.abc@aail.com",
    "userName": "Miaai",
    "userSurname": "dsith",
    "isRead": false,
    "dossierId": "#88:1"
}]

1 个答案:

答案 0 :(得分:1)

在underscorejs http://underscorejs.org/#union

中使用union
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
=> [1, 2, 3, 101, 10]