我试图获取数组的大小,但每次控制台都说我未定义,并且不知道为什么。在Angular-JS中获取数组大小
.success(function (data) {
console.log('Random-Suffix:' + suffix);
$scope.builds = new X2JS().xml_str2json(data);
var size = $scope.builds.length;
console.log('Size: ' + size);
$timeout(function() {
$scope.exampleLiveDataChange();
}, 3000);
})
'console.log($ scope.builds)'的输出是什么? – Manwal 2015-03-31 08:48:16
尝试'console.log(typeof($ scope.builds))''你很可能会看到'$ scope.builds'不是一个数组!您可能需要输出它并在其中查找您的数组; – Fourat 2015-03-31 09:07:20