javascript - Copying object properties to new/another object using AngularJS -


I am thinking that the best way to copy the item from / to the object is AngularJS / JavaScript

The Jason object below is:

  {"application": {"number": "323-23-4231", "zodiac": "234.44", "ref_name" : "E.E.", "last_name": "Schultz", "date_of_birth": "1975": "EMERGY" "" ("555) 555-5555", "type": "mobile"}]}}   Code>  

want to use the above Jason object That I see the new JSON object data like this:

  {"number": "323-23-4231", "zodiac": "234.44", "ref_name": "Thomas Edison" "Date_of_birth": "1975/09/29", "EMAIL_ADDRESS": "ere", "middle_name": "e", "last_name": "shulz", "prefix" Myemail@HOTMAIL.COM "," phone ": [{" number ":" (555) 555-5555 "," type ":" mobile "}]}    

If you have a variable called the oldObj in the original object, then

  newObj = {} newObj = angular.extend (newObj, oldObj.application) newObj = angular.extend (newObj, oldObj.borrower)   

There are so many ways to copy the properties can not create object. Angular has the built in angular.extend , which you can read about

You can do this without any fancy way:

 < code> newOb .number = oldObj.application.number newObj.amount = oldObj.application.amount newObj.ref_name = oldObj.application.ref_name newObj.prefix = oldObj.borrower.prefix ...   < P> But that would be a little silly :)   

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -