我有一个问题,使用Node和Angular从JSON(来自MongoHQ的BSON)读取嵌套数组。NodeJS/AngularJS - 从JSON读取对象数组
JSON片段:http://pastie.org/9305682。特别注意边缘数组。
猫鼬模型:http://pastie.org/9305685
基本上我打电话从数据库中的字符,然后尝试将其与 的console.log(炭)登录到控制台上;,然后将其发送回角度呼叫res.json(char);'char'是数据库中返回的保存为我的猫鼬模型的字符。
试图将角色登录到控制台。 除了嵌套“效果”阵列的部分外,我看到的一切看起来都正常。任何地方,他们显示我收到以下:
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] } ],
从这里,如果我尝试调用它:
从的NodeJS - 的console.log(焦[0] .edges [0]。影响[0] .TYPE); - 返回未定义。
从角度视图 - {{cur_char.edges [0] .effects [0] .type}} - 什么都不显示。
在此先感谢您的帮助。让我知道如果我可以提供更多的英寸
你试过只是CONSOLE.LOG(的char [0] .edges [0]影响[0]),看是否对象被返回JSON? – JoshSGman
调用这个我得到[对象对象]。 – Tyrrexx