I have this output when I do a console log:
What I want to do is access all five elements but I can't do it. If I do this.tempLines[0]
it says that is undefined. Same with this.tempLines[0][0]
for example. And same with this.tempLines.lines
The only thing that prints is when I do this.tempLines
.
This is the way I push elements to tempLines
. I did that to store data inside a subscribe:
retrieveLines(){
this.lineService.getAll().subscribe(result=>{
this.lines=result;
for(let data of this.lines) {
this.tempLines.push(data)
}
});
}
And finally I declare my two array vars like this
lines:any=new Array<any>();
public tempLines:any=new Array<any>();
PS: I know there is many redundancy but I do that because I want to store outside the subscribe method the list of lines to use it in other methods and if I just say that this.lines= result
when I console log outside subscribe method I have nothing.