Javascript TypeError:无法读取属性';推动';未定义的

Javascript TypeError:无法读取属性';推动';未定义的,javascript,angularjs,angularjs-scope,Javascript,Angularjs,Angularjs Scope,我试图将“currentBall”对象推入“currentOver.balls”数组 $scope.currentOver.balls.push($scope.currentBall); 运行上述代码之前两个对象的当前状态(来自开发工具): 我收到一个错误:无法读取未定义的属性“push”。但是很明显,“$scope.currentOver.balls”数组已经定义,所以这里发生了什么?很难从您引用的“当前状态”中分辨出来,因为我怀疑重要的缩进已经丢失,但它看起来像是currentOver,作

我试图将“currentBall”对象推入“currentOver.balls”数组

$scope.currentOver.balls.push($scope.currentBall);
运行上述代码之前两个对象的当前状态(来自开发工具):


我收到一个错误:
无法读取未定义的属性“push”
。但是很明显,“$scope.currentOver.balls”数组已经定义,所以这里发生了什么?

很难从您引用的“当前状态”中分辨出来,因为我怀疑重要的缩进已经丢失,但它看起来像是
currentOver
,作为一个数组,包含一个带有
balls
属性的条目(而不是拥有自己的
balls
属性)。因此:

让我想到的关键点是:

$scope.currentOver: Array[1] <== Here, we're seeing that it's an array with one entry 0: Object <== This looks like it's about to show us what that entry is balls: Array[0] <== And so I suspect this is in the entry, not the array bowlerId: 0 ...
$scope.currentOver:Array[1]啊,当然-这是有道理的。实际上我不希望
currentOver
成为一个数组,而是一个对象。非常感谢您的帮助
$scope.currentOver[0].balls.push($scope.currentBall);
$scope.currentOver: Array[1] <== Here, we're seeing that it's an array with one entry 0: Object <== This looks like it's about to show us what that entry is balls: Array[0] <== And so I suspect this is in the entry, not the array bowlerId: 0 ... $scope.currentOver: Array[1] 0: Object balls: Array[0] bowlerId: 0 ...