在 Angular js 中访问数组中的各种元素



我正在使用Angular js和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);
    }
  });
};

我有一个来自太妃糖数据库的数组结果,如下所示。团队数据包含

[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]

我必须在表格中显示每个元素。

如何访问上述数组中的每个元素?

请指教

angular.forEach 对于数组的签名如下:

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

因此,您应该能够像这样访问每一行:

angular.forEach(teamdata, function(row) {
  // ... row.text
});

Angular.for每个文档

最新更新