Abdul Majeed Abdul Majeed - 1 year ago 103
Javascript Question

Push is not working

After reading data with the help of for Each loop. Data is populating successfully.
I am trying to push objects in an array named test Data but it fails. Push is not working.
Below is my code.

data.content.forEach(function(column) {
var objects = {
ip: "",
user: "",
objects.ip = column.ip;
objects.user = column.username;
var d = new Date(column.created);
var a = d.toUTCString();
objects.date_created = a;
}, function(error){

Answer Source

if you see at line no 1 you declared an array $scope.testData = [];

so you need to use $scope.testData.push(objects)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download