RangeError最大调用堆栈大小超出了AngularJS

时间:2018-10-10 16:37:24

标签: angularjs angularjs-directive angularjs-scope

我是AngularJS的新手。 从脚本开始在开发中就可以正常工作,然后上传到生产环境后,我的Controller中出现RangeError。我对这个错误感到困惑,即使我使用Google搜索仍然无法解决:(

这是我在routeProvider上的脚本:

    .when('/customer/detail/:id', {
    title: 'Customer Detail',        
    templateUrl: 'templates/customer_detail.html',
    resolve: {
        app: function($q, $rootScope, $location, roles) {
            var defer = $q.defer();
            if (roles.pageCustomer !== true) {
                $location.path('/main.html');
            };
            defer.resolve();
            return defer.promise;
        }
    }
})

然后在我的控制器上:

app.controller('ctrl_customer_list', function($scope){

        $scope.title    = "Customer List";


        $('#datatable_customer').DataTable({
            bServerSide: true,
            bDestroy: true,
            responsive: true,
            iDisplayLength: 250,
            serverSide: true,
            columnDefs: [ {
            targets: 0,
            orderable: false,
            targets : 1,
            "render": function ( data, type, row, meta ) {
            var itemID = row[8];                   
            return '<a href="customer/detail/' + itemID + '">' + data + '</a>';
            }                     
        }],
            lengthMenu: [ 10, 25, 50, 75, 100, 250, 500, 1000 ],         
            aaSorting: [[1, 'asc']],
            ajax:{
                    url :"backend/customer/list", // json datasource
                    type: "post",  // type of method  ,GET/POST/DELETE
                    error: function(){
                                        $("#datatable_processing").css("display","none");
                                    }
            },
            language: {
                    searchPlaceholder: 'Search...',
                    sSearch: '',
                    lengthMenu: '_MENU_ items/page',
            }

    });

    $('.dataTables_length select').select2({ minimumResultsForSearch: Infinity });

});

代码制作完成后出现以下错误:

RangeError: Maximum call stack size exceeded
at Function.n.extend.n.fn.extend (jquery.js:177)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
at Function.n.extend.n.fn.extend (jquery.js:228)
(anonymous) @ angular.js:15536
(anonymous) @ angular.js:11815
(anonymous) @ angular.js:21559
Pg.completeTask @ angular.js:21194
(anonymous) @ angular.js:6790
setTimeout (async)
h.defer @ angular.js:6788
f @ angular.js:21554
(anonymous) @ select2.js:194
(anonymous) @ angular.js:1365
Ba @ angular.js:11235
q @ angular.js:10554
g @ angular.js:9801
g @ angular.js:9804
g @ angular.js:9804
g @ angular.js:9804
g @ angular.js:9804
q @ angular.js:10548
g @ angular.js:9801
g @ angular.js:9804
g @ angular.js:9804
q @ angular.js:10548
g @ angular.js:9801
(anonymous) @ angular.js:9666
link @ angular-route.js:1260
(anonymous) @ angular.js:1365
Ba @ angular.js:11235
q @ angular.js:10554
g @ angular.js:9801
(anonymous) @ angular.js:9666
(anonymous) @ angular.js:10080
d @ angular.js:9844
m @ angular.js:10604
C @ angular-route.js:1209
$broadcast @ angular.js:19683
(anonymous) @ angular-route.js:749
(anonymous) @ angular.js:17914
$digest @ angular.js:19075
$apply @ angular.js:19463
k @ angular.js:13312
w @ angular.js:13569
E.onload @ angular.js:13474
load (async)
(anonymous) @ angular.js:13457
s @ angular.js:13257
(anonymous) @ angular.js:12998
(anonymous) @ angular.js:17914
$digest @ angular.js:19075
$apply @ angular.js:19463
(anonymous) @ angular.js:15270
dispatch @ jquery.js:4435
r.handle @ jquery.js:4121

我正在使用AngularJS 1.7.5和GruntTasker。 有什么建议吗?非常感谢您的帮助 (对不起,我的英语)

1 个答案:

答案 0 :(得分:2)

只需更新即可解决问题。首先,我按照@numbtongue的说明进行操作。终于发现问题来自AngularJS-select2。我试图从存储库中删除AngularJS-select2并最终成功了!

非常感谢@numbtongue作为使用Chrome进行指令调试的方法。

PS: 使用调试器,您可以查看一次执行多少个脚本。