AngularJS 10 $digest() 迭代在列表显示时达到



我的js代码是:

// 在变更分布的时候,重新获取数据条目
$scope.reGetProducts = function(){
        // 发送给后台的请求数据
        $scope.model.cpage=$scope.paginationConf.currentPage;
        $scope.model.len=$scope.paginationConf.itemsPerPage;
        $http({
            method  : 'POST',
            url     : '<%=request.getContextPath()%>/sysConfigManage/querySysConfigList.action',
            data    : $scope.model,  // pass in data as strings
            headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  // set the headers so angular passing info as form data (not request payload)
        }).success(function(data){
            // 变更分页的总数
            $scope.paginationConf.totalItems = data.total;
            // 变更列表条目
            $scope.items = data.rows;
        });
    };
    // 配置分页基本参数
    $scope.paginationConf = {
        currentPage: 0,
        itemsPerPage: 10
    };
    $scope.model = {};
    $scope.items = {};
    // 通过$watch currentPage和itemperPage 当他们一变化的时候,重新获取数据条目
    $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage',$scope.reGetProducts);

而 html 是

<tr bindonce ng-repeat="item in items">
    <td>
        <button type="button" class="btn btn-success" ng-click="getDetaile(item.ID)">详情</button>
        <button type="button" class="btn btn-danger"  ng-click="del(item.ID)">删除</button>
    </td>
    <td bo-text="item.NAME"></td>
    <td bo-text="item.CODE"></td>
    <td bo-text="item.VALUE"></td>
    <td bo-text="item.MEMO"></td>
</tr>

为什么错误课程,请帮助我,,,..

问题就在这里:

 $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage',$scope.reGetProducts);

您正在监视一项永远不会稳定的操作。在每个摘要调用中,角度比较计算结果并比较两个新对象。

在此处阅读更多内容: https://docs.angularjs.org/error/$rootScope/infdig

因此,角度不能确定稳定的模型。你可以很容易地写出来:

$scope.$watchGroup(['paginationConf.currentPage', 'paginationConf.itemsPerPage'], $scope.reGetProducts);

最新更新