Uncaught TypeError: data.push is not a function

前端 未结 8 1493
半阙折子戏
半阙折子戏 2020-12-04 23:45

I am trying to push

data.push({\"country\": \"IN\"});

as new id and value to a json string. but it gives the following error



        
8条回答
  •  攒了一身酷
    2020-12-05 00:03

    Try This Code $scope.DSRListGrid.data = data; this one for source data

                for (var prop in data[0]) {
                    if (data[0].hasOwnProperty(prop)) {
                        $scope.ListColumns.push(
                                {
                                    "name": prop,
                                    "field": prop,
                                    "width": 150,
                                    "headerCellClass": 'font-12'
                                }
                        );
                    }
                }
                console.log($scope.ListColumns);
    

提交回复
热议问题