遍历数组报错:cannot read property ‘forEach’ of undefined
在遍历之前,判断数组是否存在
$scope.list=[];
//遍历之前,判断数组是否存在
if(!$scope.list){
return;
}
$scope.list.forEach(function(item,i){
console.log(item);
})
遍历数组报错:cannot read property ‘forEach’ of undefined
在遍历之前,判断数组是否存在
$scope.list=[];
//遍历之前,判断数组是否存在
if(!$scope.list){
return;
}
$scope.list.forEach(function(item,i){
console.log(item);
})