我想在javascript中訪問一個數組鍵值。在javascript對象內部訪問數組鍵值
這裏是我的.js文件:
var contentData = [
{
tops: [
{ image: "images/top1.jpg" },
{ image: "images/top2.jpg" },
{ image: "images/top3.jpg" },
{ image: "images/top4.jpg" } ]
}
];
$scope.objectArray = contentData;
$scope.objectCount = $scope.objectArray[0].length;
我試圖訪問「頂」內部「contentData內容」,顯示「頂部」數組的長度應該有四個
應該是'$ scope.objectArray [0] .tops.length' –