Suraz Khanal Suraz Khanal - 1 year ago 83
AngularJS Question

How to append object into existing object Angularjs

i have two object one is for just to hold answer of one question and another is final object. like

answer = {"value":"asda","indicator":"good"};
final = {} ;

i want to append answer object to final object like this

final = {{"value":"asda","indicator":"good"},{"value":"sdad","indicator":"worse"}}

How can i do that ?

Answer Source

You can not directly append object. Instead of this you need to hold object in an array like following.

answer = {"value":"asda","indicator":"good"};
final = [];
newObject = {"value":"sdad","indicator":"worse"};

now you can push both object to array like -


Result of this will be -

final = [{"value":"asda","indicator":"good"},{"value":"sdad","indicator":"worse"}];

Hope this will help you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download