Udit Udit - 6 months ago 29
JSON Question

How can I merge two json objects in same array by Id in another array?

I have a a big json array and have many objects and arrays inside it.
I want to merge two types of objects together.

For example : 1-10 stands for froms and
11-20 stands for Tos
So I want to merge Ṭos and froms and instead of showing them 1-20. I want to show 1-11, 2-12 and respectively.
How can I achieve this in angularJs.


you can use simple javascript to do this.

Iterate halfway through the originalArray using an index variable and push elements from both the ranges at the same time in a new array.

var newArray = [];
for (var i=0; i<10; i++){

I've assumed 20 as the original array length from your example. You can always use array's length property to calculate required values.