I'm working with Angular (so typescript) on a projet. I try to iterate over an object
I build an object in a service like so :
class Point {
id: number;
name: string;
constructor(id: number, name: string) {
this.id = id;
this.name = name;
}
}
I fill an array with theses points that i get from a database
private pointList: Point[] = [];
I make a fonction to get back theses points in other 'components' in angular
getPointsList() {
return this.pointList;
}
all of this is done in a points.service.ts
So the problem is,
In an other component i load those points in a local variable
pointList = this.pointsService.getPointsList();
en then i try to iterate over them like so :
console.log(this.pointList); // first consoleLog
for (const point of this.pointList) {
console.log(point); // second consoleLog
console.log(point.id); // third consoleLog
}
all of this is done in an other file, in a component, map.ts
the results of the console.log are :
an array containing my objects like : [{id: 1 name: 'test' } { id: 2 name: 'test2' }] an that's normal i think
nothing
nothing
so i think that it don't event enter the for loop but i don't see why.
i also tried
to
console.log(this.pointList[0])but it return an undefinethis.pointList.forEach(point => {console.log(point)});but it didn't print anything
here is my 'real' code and what it show in the console :
can someone tell me what i'm doing wrong ?
thanks


console.log(JSON.stringify(this.pointList));, what do you get?