AngularJS - How to append json to another json object? AngularJS - How to append json to another json object? json json

AngularJS - How to append json to another json object?


This is just vanilla javascript. You want to make an array of from the objects.

var object1 = {  "key1": "value one",  "key2": "value two"}var object2 = {  "key1": "value three",  "key2": "value four"}var object3 = []; // empty array// add the other objects to the arrayobject3.push(object1);object3.push(object2);

if your objects are already arrays and you just want to concatenate them, you can use the concat function on arrays.

var object1 = [{  key: 'abc',  value: 1}];var object2 = [{  key: 'cbd',  value: 2}];// use the concat function to concatenate the arraysvar object3 = object1.concat(object2);

You can find more about arrays by reading the documentation found here.

If your objects are firebaseArray objects they have their own API. More can be found here.