1
위치 이름별로 재고가 얼마나 있는지 세고 있습니다. 모든 작동하지만, location name = null
경우 난 내 콘솔에서 오류가 발생할 수 Cannot read property 'name' of null
AngularJS의 null 값 오류
$scope.stored = function(name) {
$scope.count = 0;
for(var i = 0; i < $scope.inventories.length; i++){
if($scope.inventories[i].location.name == name){
$scope.count = $scope.count + 1;
}
}
return $scope.count;
};
을 변경해야 if ($ scope.inventories [i] .location.name == name) {'to'if ($ scope.inventories [i] .location && $ scope.inventories [i] .location.name == name) { ' –
중복 가능 [null 길이의 속성을 읽을 수 없습니다 (자바 스크립트)] (http://stackoverflow.com/questions/15731559/c) annot-read-property-length-of-null-javascript) –