【发布时间】:2020-06-03 07:12:47
【问题描述】:
我的数据数组
data:[
0:{
id:1 ,.....
competetion:[
0:{
id: 1....,
match:[
0:{id: 1 ......},
1:{same}
.
.
]
1:{same}]},
2:{same}
.
.
]
},
1:{same},
2:{same}
.
.
.
]
对于data[],我可以创建一个带有推送元素的新数组(sportarr[]),但我想在同一个数组sportarr[] 中创建与competetion[] 和match[] 相同的数组
如果有任何其他方法可以做到这一点,请帮助我...
我的代码:我正在循环它:
this.sportsSidebar = response.data; // My data Array (this.sportsSidebar)
const arrlength = response.data.length;
for (let i = 0; i < arrlength; i++) {
this.sportarr.push({ // I declared a new array where i want to push the element
id: i,
value: false
});
}
【问题讨论】:
标签: arrays angular typescript for-loop multidimensional-array