Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何在控制台中显示阵列数据?_Angular_Ionic Framework - Fatal编程技术网

Angular 如何在控制台中显示阵列数据?

Angular 如何在控制台中显示阵列数据?,angular,ionic-framework,Angular,Ionic Framework,我需要控制台已经在数组中的数据。这是数据,看起来像这样 我得到这样的数据 this.clientData.subscribe(udata=>{ console.log(udata); console.log(udata.records.name);您错过了索引 this.clientData.subscribe(udata => { console.log(udata); console.log(udata.records[0].name); <=== her

我需要控制台已经在数组中的数据。这是数据,看起来像这样

我得到这样的数据

this.clientData.subscribe(udata=>{
console.log(udata);

console.log(udata.records.name);您错过了
索引

this.clientData.subscribe(udata => {
     console.log(udata);
     console.log(udata.records[0].name);  <=== here use indexing
})
this.clientData.subscribe(udata=>{
console.log(udata);

console.log(udata.records[0].name);它是一个数组,因此要访问数据,还需要写入索引

 this.clientData.subscribe(udata => {
    console.log(udata);
    console.log(udata.records[0].name);// 0 is the index of the records array and name is the key so it will print the name key value 
 })

你可能想要的是一张地图

 console.log(udata.records.map(({ name }) => name);


如果Udata也在数组中,则应再次迭代它

udata.forEach(element=>{
   console.log(element.records.name)
})
或udata.records

udata.forEach(element=>{
   console.log(element.records.name)
})