Javascript 使用单击调用angularJS TypeError时,angularJS TypeError不是函数

Javascript 使用单击调用angularJS TypeError时,angularJS TypeError不是函数,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我收到的错误如下 TypeError: undefined is not a function at Scope.$scope.AddCardToList html中的代码 <button type="button" ng-if="$index == 0" class="btn btn-default btn-xs" ng-click="AddCardToList(card)">{{edition.multiverse_id}}</button> 每当我尝试在$sc

我收到的错误如下

TypeError: undefined is not a function
at Scope.$scope.AddCardToList
html中的代码

 <button type="button" ng-if="$index == 0" class="btn btn-default btn-xs" ng-click="AddCardToList(card)">{{edition.multiverse_id}}</button>
每当我尝试在$scope.decklist数组中推卡时,我都会得到一个未定义的值,但我看不到 但是当我不尝试在数组中推送对象时,函数和对函数的调用工作得很好

有没有一种更好的方法来创建和推送/弹出角度数组中我看不到的对象


提前谢谢

你是说
$scope.decklist=[]
而不是
{}
Push是数组上的函数,而不是对象文本上的函数。或者只做
$scope.decklist=$scope.decklist | |[]是的,我是个白痴!我继续阅读,以便调用空数组是$scope.decklist={};很有效,谢谢你,好先生!
$scope.AddCardToList = function (card) {
        if (!$scope.decklist) { $scope.decklist = {}; }
        $log.info("Adding " + card.name + " to your decklist.");
        $scope.decklist.push(card);
    };