I have a for loop, that adds data into an array.
but when I console.log the array, it is full of the last item of the for loop!
Here is my code :
var materialsData = results[1].data, // results[1].data is a http.get return
ln = Object.size(materialsData),
materials = [],
material = {};
material['Product'] = {};
for (var i = 0; i < ln; i++) {
material.Product['Name'] = materialsData[i].Product.Name;
material.Product['Id'] = materialsData[i].Product.Id;
material.StartingDate = materialsData[i].StartingDate.replace("T00:00:00", "").split('-').reverse().join('-');
material.Device = materialsData[i].Device;
materials.push(material);
}
material?