Question

I am building an application using Angular js and Taffy DB.

javascript:

$scope.viewTable=function () {
  $scope.resultlists=[];
  $scope.resultSet=teamlist().get();
  var teamdata=$scope.resultSet;
  angular.forEach(teamdata,function(teamdata,i){
    if (i<length) {
    console.log(teamdata[i].text);
    }
  });
};

I have an array result from Taffy DB like this. teamdata contains

[Object { text="zxcxzc", $$hashKey="00A", ___id="T000002R000002", more...}, Object { text="czxcz", $$hashKey="00C", ___id="T000002R000003", more...}, "zxczxc", Object { undefined={...}, ___id="T000002R000005", ___s=true}, 5454575, Object { undefined={...}, ___id="T000002R000007", ___s=true}, 2, 2727287.5]

and I have to display each element in a table.

How to access each element in the above array?

Please Advice

Was it helpful?

Solution

The signature of the angular.forEach for arrays is as follows:

angular.forEach(array, function(element) { ... })

So you should be able to access each row like that:

angular.forEach(teamdata, function(row) {

  // ... row.text
});

angular.forEach documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top