Why is this code not functioning properly in TypeScript?
For example:
views: any[] = [360001232825, 360001232845, 360001217389];
myArray:any[];
for (var i = 0; i < this.views.length; i++) {
this.subscription = this.dataService.getMyData(this.views[i]).subscribe(data => {
this.myArray[this.views[i]]=data;
});
}
Instead of using .push
, I want to insert data into my array at a specific index.