I am encountering an issue while trying to fetch data from an array, as I keep receiving undefined
Please refer to the image for a visual representation of my problem.
I'm not sure what I might be overlooking, so any help would be greatly appreciated.
The array in question is named nameTable
and consists of strings.
- Upon executing
console.log(this.nameTable)
, the output shown can be viewed in the attached image.
Additionally, upon further investigation by clicking the arrow, the result depicted in the second image was observed:
The main challenge arises when attempting to display the 5 elements within the table using a for loop.
for (let i = 0; i < 5; i++){
console.log(this.nameTable[i])
}
Despite the intended logic, as showcased in the provided image, the output returned happens to be undefined
.
Given below is a snippet of the code highlighting the relevant section:
// Relevant Code Section
employeeL:Array<Awinjard> = [];
inv_agentTab: Array<Inv_agent> = [];
drafbiesTab: Array<Drafbies> = [];
// Additional Declarations
// Initialization in ngOnInit Method
nameTable:Array<string> = [];
ngOnInit() {
this.folder = this.activatedRoute.snapshot.paramMap.get('id');
this.awinjard.getAwinjardMatricule().subscribe(res => {
// Further Implementation Logic
})
}