嵌套for循环不起作用。句法?

时间:2017-11-10 15:56:34

标签: angular typescript firebase ionic2 angularfire2

为什么这段代码不起作用?第二个循环中的console.log不会触发。

url = 'www.party.com'

我想得到的数据:

enter image description here

url = 'http://www.party.com'给出以下输出:

Where the arrow shows is the nested object I need

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

迭代一个对象与迭代一个数组不同,你可以使用for-in迭代对象:

for(var i in data){
  for(var j in data[i]){
    console.log(data[i][j]);
    studys2.push(data[i][j]);
  };
};

希望这有帮助。