我的回复是
data [4] { {
_id:"1" description:"desc" languageId:"5" title:"ttitle" } { [1]:
_id:"2" description:"desc1" languageId:"4" title:"title2" } { [2]:
_id:"3" description:"desc3" languageId:"4" title:"title2" } [3]:
_id:"4" description:"desc4" languageId:"4" title:"title2" } }
并需要将其拆分为
{
[0]:Object
description:"desc"
title:"ttitle"
description1:"desc1"
title1:"title2"
}
{
[1]:Object
description:"desc3"
title:"ttitle"
description1:"desc4"
title1:"title2"
}
这是angularjs。请帮忙。我尝试过使用推送和合并。提前谢谢。
答案 0 :(得分:0)
我无法确定你在问什么。这是你想要的吗?
http://plnkr.co/edit/yWc36FmiBs6gMaXBq9on?p=preview
kickstart
示例输入:
ISO
示例输出:
function split(data) {
var results = [];
for (var i = 0; i < data.length; i += 2) {
var j = i + 1;
var result = {
description: data[i].description,
description1: data[j].description,
title: data[i].title,
title1: data[j].title,
};
results.push(result);
}
return results;
}