私の目的は(テーブルの行として)オブジェクトから配列を作成することですが、私は$ rootScope:infdigエラーを取得します。私は同様の質問here見てきましたが、それは助けにはならなかった
$scope.rows = {
"TableName": "TestTable",
"Rows": [{
"Name": "Name1",
"RowCells": [{
"Y": 2001,
"M": 164
}, {
"Y": 2002,
"M": 178
}, {
"Y": 2003,
"M": 188
}, {
"Y": 2007,
"M": 295
}, {
"Y": 2008,
"M": 316
}, {
"Y": 2009,
"M": 328
}]
}],
"Rows": [{
"Name": "Name2",
"RowCells": [{
"Y": 2001,
"M": 164
}, {
"Y": 2002,
"M": 178
}, {
"Y": 2003,
"M": 188
}, {
"Y": 2007,
"M": 295
}, {
"Y": 2008,
"M": 316
}, {
"Y": 2009,
"M": 328
}]
}],
"Rows": [{
"Name": "Name3",
"RowCells": [{
"Y": 2001,
"M": 164
}, {
"Y": 2002,
"M": 178
}, {
"Y": 2003,
"M": 188
}, {
"Y": 2007,
"M": 295
}, {
"Y": 2008,
"M": 316
}, {
"Y": 2009,
"M": 328
}]
}]
}
$scope.rowCells = function() {
var tableRowCollection = [];
angular.forEach($scope.rows, function (item) {
var tableRow = [];
tableRow.push(item.Name);
angular.forEach(item.RowCells, function (i) {
tableRow.push(i.M);
});
tableRowCollection.push(tableRow);
});
return tableRowCollection ;
};
<div data-ng-repeat="r in rowCells()">{{r}}</div>
:
は、ここに私のコードです。 私は何が不足していますか、どこが間違っていますか?
あなたは正しいです、私のオブジェクトに誤りがありましたが、私は例を作成している間に、これはのみで滑っている、実際のオブジェクトはokです。 – agri