I have an array that contains cameras specifications, the problem occurs when I try to run a for loop to get the elements.
Here is the content of my array :
I tried all different types of for loops like forEach, basic for loop with increment or for (let item of myArray
)
For loop doesn't run and I have no return of the element in the array.
for (let id in elements) {
if (typeof elements[id].brands !== 'undefined') {
delete this.items;
let itemsArray = [];
for (let elementData of elements[id].brands) {
this.http.get("assets/data/" + elementData + "Reflex.json").map(res => res.json()).subscribe(data => {
Array.prototype.push.apply(itemsArray, data);
});
}
this.items = itemsArray;
}
if (typeof elements[id].sensorSize !== 'undefined') {
}
}
(this.items
is the array that you can see on the top (I use Angular2)).