我的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);
您正在观看一场永远不稳定的行动。在每个摘要调用中,Angular 都会比较计算结果并比较两个新对象。
在此处了解更多信息:https://docs.angularjs.org/error/ $rootScope/infdig
因此 Angular 无法确定稳定的模型。您可以轻松地编写:
$scope.$watchGroup(['paginationConf.currentPage', 'paginationConf.itemsPerPage'], $scope.reGetProducts);
关于javascript - AngularJS 10 $digest() 迭代达到列表显示时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27888457/