Thursday, 15 July 2010

javascript - NodeJS/AngularJS - Reading Array of Objects from JSON -



javascript - NodeJS/AngularJS - Reading Array of Objects from JSON -

i've got issue reading nested array json(bson mongohq) using node , angular.

json snippet: http://pastie.org/9305682. edges array.

mongoose model: http://pastie.org/9305685

basically phone call character db , effort log console console.log(char); before sending angular phone call res.json(char); 'char' returned character databased saved mongoose model.

attempting log character console. i looking normal except portions nested "effects" arrays. anywhere show receive following:

edges: [ { name: 'super hacker', notes: '', effects: [object] }, { name: 'witty', notes: '', effects: [object] }, { name: 'attractive', notes: '', effects: [object] }, { name: 'encyclopedic memory', notes: 'prereq: d8 smarts', effects: [object] }, { name: 'daywalker', notes: '', effects: [object] }, { name: 'tough', notes: '', effects: [object] } ],

from here if seek phone call with:

from nodejs - console.log(char[0].edges[0].effects[0].type); - returns undefined.

from angular view - {{cur_char.edges[0].effects[0].type}} - displays nothing.

thanks in advance help. allow me know if can provide more in.

i think you're asking how see more depth object in console output. can utilize util.inspect print out more information:

console.log(util.inspect(char, { depth: 5 }));

by default util.inspect goes depth of 2 explains why can see contents of array (1) , primitive properties of each element in array (2).

see: http://nodejs.org/api/util.html#util_util_inspect_object_options

javascript json node.js angularjs mongodb

No comments:

Post a Comment