Javascript 无法读取属性';推动';未定义角度的定义

Javascript 无法读取属性';推动';未定义角度的定义,javascript,angularjs,frontend,Javascript,Angularjs,Frontend,我的目标是从API获取的数据创建一个数组。但是,它不断向我显示无法读取未定义Javascript的属性“push”的错误 有人能给我指路吗 代码如下: myService.getData().then(function (res) { $scope.resoureceGroupsRawData = res.data; //declare an array already... $scope.resourceGroupIte

我的目标是从API获取的数据创建一个数组。但是,它不断向我显示
无法读取未定义Javascript的属性“push”的错误

有人能给我指路吗

代码如下:

 myService.getData().then(function (res) {
            $scope.resoureceGroupsRawData = res.data;
            //declare an array already...
            $scope.resourceGroupItems = new Array();

        }, function(error) {
           throw error;
        }).then(function() {
            _.forEach($scope.resoureceGroupsRawData, function(text, idx) {
                var item = {};
                item.id = idx++;
                item.label = text;
                //why it says resourceGroupItems is null?
                $scope.resouceGroupItems.push(item);
            });
        }, function(err) {

        });
错别字兄弟, 你在几个地方错卖了资源

myService.getData().then(function (res) {
            $scope.resourceGroupsRawData = res.data;
            //declare an array already...
            $scope.resourceGroupItems = new Array();

        }, function(error) {
           throw error;
        }).then(function() {
            _.forEach($scope.resourceGroupsRawData, function(text, idx) {
                var item = {};
                item.id = idx++;
                item.label = text;
                //why it says resourceGroupItems is null?
                $scope.resourceGroupItems.push(item);
            });
        }, function(err) {
            //TODO need add error page here
        });

出现错误的行上的
resourceGroupItems
缺少第二个“r”。您声明为
$scope.resourceGroupItems=new Array()并用作
$scope.resourceGroupItems.push(项目)。错过了一个
r
@catlovespurple虽然正确,但这个答案没有帮助。请加上解释。