My jsbin link is here: http://jsbin.com/siyux/1/edit

Below is my code:

var dest = {
   owner: '53a96efe07b7570013bdcb8b',
 schedule: 'Thu Jul 03 2014 20:00:00 GMT+0530 (India Standard Time)',
 _id: '53b55f52dafac9f40984fe30',
 __v: 0,
 a: [],
  result:{
   markCard: [] 
  },
 parent: {},
 b: [],
 c: [],
 d: { teamRef: '53ad727d62290bc8178695fa', squad: [] },
 e: { teamRef: '53ad726e62290bc8178695f9', squad: [] } 
};

var src = {
  markCard:
   [ { i: 1,
       bt: [Object],
       bl: [Object],
       ts: [Object],
       sc: [Object] },
     { i: 2,
       bt: [Object],
       bl: [Object],
       ts: [Object],
       sc: [Object] } ],
  srcA:
   { __v: 0,
     _id: '53ad726e62290bc8178695f9',
     name: 'T-H',
     owner: '53a96efe07b7570013bdcb8b' },
  srcB: { __v: 0,
     _id: '53ad726e62290bc8178695f0',
     name: 'T-M',
     owner: '53a96efe07b7570013bdcb8b' },
  srcC: false,
  srcD: 'Bt'
};

//console.log(_.merge(dest, src));
dest.result=_.extend(dest.result, src);
console.log(dest);

*Expected Output:*

dest = {
       owner: '53a96efe07b7570013bdcb8b',
     schedule: 'Thu Jul 03 2014 20:00:00 GMT+0530 (India Standard Time)',
     _id: '53b55f52dafac9f40984fe30',
     __v: 0,
     a: [],
      result:{
      markCard:
       [ { i: 1,
           bt: [Object],
           bl: [Object],
           ts: [Object],
           sc: [Object] },
         { i: 2,
           bt: [Object],
           bl: [Object],
           ts: [Object],
           sc: [Object] } ],
      srcA:
       { __v: 0,
         _id: '53ad726e62290bc8178695f9',
         name: 'T-H',
         owner: '53a96efe07b7570013bdcb8b' },
      srcB: { __v: 0,
         _id: '53ad726e62290bc8178695f0',
         name: 'T-M',
         owner: '53a96efe07b7570013bdcb8b' },
      srcC: false,
      srcD: 'Bt'
    },
     parent: {},
     b: [],
     c: [],
     d: { teamRef: '53ad727d62290bc8178695fa', squad: [] },
     e: { teamRef: '53ad726e62290bc8178695f9', squad: [] } 
    };

*Actual Output*

dest = {
       owner: '53a96efe07b7570013bdcb8b',
     schedule: 'Thu Jul 03 2014 20:00:00 GMT+0530 (India Standard Time)',
     _id: '53b55f52dafac9f40984fe30',
     __v: 0,
     a: [],
      result:{
      markCard:
       [ { i: 1,
           bt: [Object],
           bl: [Object],
           ts: [Object],
           sc: [Object] },
         { i: 2,
           bt: [Object],
           bl: [Object],
           ts: [Object],
           sc: [Object] } ],
      srcA:
       {  },
      srcB: { }
      },
     parent: {},
     b: [],
     c: [],
     d: { teamRef: '53ad727d62290bc8178695fa', squad: [] },
     e: { teamRef: '53ad726e62290bc8178695f9', squad: [] } 
    };

As a result of extending, I am not able to extend the values of srcA, and 
srcB to the destination. Only the structure gets copied i guess. Some one 
please let me know where I am wrong. Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to