javascript - dxDataGrid 使用 ngResource 触发对所有类型的 Web api 的无限调用(错误 : [$rootScope:infdig] 10 $digest() iterations reached. 中止!)

标签 javascript angularjs asp.net-web-api devextreme

我正在使用 dxDataGrid 通过我们的 WebApi (MVC .net) 显示一些数据。 在我们的服务器上,GET 函数第一次正确触发,然后 一切都变得困惑。即使请求 Controller 中根本没有对 POST、DELETE 的调用,服务器也会对 POST、DELETE、GET 进行无限调用。 正如您在下图中看到的错误所示,某些内容明显在循环

[$rootScope:infdig] 已达到 10 次 $digest() 迭代。正在中止!

Angular Problem

请求 Controller js代码:

angular.module('wdfApp.controllers')
    .controller('RequestListCtrl', ['$scope', '$http', 'Request', function ($scope, $http, Request) {

        var customStore = new DevExpress.data.CustomStore({
            load: function (loadOptions) {

                var query = Request.query();
                return query.$promise;
            }
        });


        $scope.dataGridOptions = {
            dataSource: customStore,
            remoteOperations:false
            ,
            loadPanel: {
                enabled: false
            },
            scrolling: {
                mode: "virtual"
            },
            sorting: {
                mode: "none"
            }
        };

    }]);

请求服务js代码:

angular.module('wdfApp.services')
.factory('Request', ['$resource',
  function ($resource) {
      return $resource('/api/requests/:request');
  }]);

最佳答案

AngularJS 使用一些自定义函数请求(如 $get、$post、$delete)包装 json 对象。似乎 dxDataGrid 在显示“内容”时触发它们。

为了解决这个问题,我在资源旁边使用了 $http。

关于javascript - dxDataGrid 使用 ngResource 触发对所有类型的 Web api 的无限调用(错误 : [$rootScope:infdig] 10 $digest() iterations reached. 中止!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37556849/

相关文章:

javascript - InAppBrowser event.url 始终未定义

angularjs - 如何使用 ng-bind 填充文本框?

visual-studio - nuget 找不到资源 'productupdate/productupdatebar.xaml'

c# - Web API OData 内联计数未映射

javascript - d3 : confusion about selectAll() when creating new elements

javascript - 在测试中从模态中选择“确定”按钮

javascript - jQuery 日期选择器在页面加载时隐藏时不会初始化

javascript - Angular 使用 Controller 注入(inject)并编译 HTML

javascript - AngularJS : changing a model in a $watch function

asp.net - 如何在MVC4 Web API中自定义JSON序列化名称?