0

I am new to angularjs i have 2 objects like the below

enter image description here

i have merged both the objects by using angular.merge as shown below

enter image description here

i want to display output as

{
name:"sam"
gender:"male"
   relation:{
       father:true
       mother:true
      }


}

how can i achieve above result

2
  • Do something like this: .push({relation: data}); Commented Sep 1, 2016 at 14:01
  • can u post a sample code ?? or refrence Commented Sep 1, 2016 at 14:02

2 Answers 2

1

Do it like this.

var obj1={
  name:"sam",
  gender:"male"
};
var obj2={
  father:true,
  mother:true
};
obj1.relation=obj2
console.log(obj1)
Sign up to request clarification or add additional context in comments.

Comments

0

You could simply merge the two objects like this:

var person = {
  name:"sam",
  gender:"male"
}

var relation = {
  father:true,
  mother:true
}

var merged = angular.merge(person, {relation: relation});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.