我有一个ng-repeat,它在更改正在使用的数组中时没有更新.我已经研究了很长一段时间但似乎没有任何工作.最初,当页面加载时,ng-repeat显示数据集的第一页,在获取新数据(下一页)并使用此数据设置该数组时,ng-repeat没有注意到更改并且从不填充更新的数组.如果有人能引导我朝着正确的方向前进,我将不胜感激.
gatekeeper.controller('businessController',['$scope','siteService',function($scope,siteService) { $scope.page = 1; $scope.resultsPerPage = 50; $scope.maxPaginationSite = 10; $scope.pageCount = 0; $scope.resultCount = 0; $scope.getBusinessSites = []; function getBusinessSites() { siteService.getBusinessSites($scope.page,$scope.resultsPerPage).then(function(response) { $scope.getBusinessSites = response.data; console.log($scope.getBusinessSites); $scope.resultCount = response.data[0].QueryCount; $scope.page = response.data[0].Page; $scope.pageCount = Math.ceil($scope.resultCount / 50); }); } getBusinessSites(); $scope.pageChanged = function () { $scope.page = this.page; getBusinessSites($scope.page,$scope.resultsPerPage); };
}]);
<tbody ng-controller="businessController"> <tr ng-repeat="site in getBusinessSites"> <td>{{ site.SiteName }}</td> <td class="tableButton"> <button ng-controller="ModalCtrl" type="button" class="btn btn-default" ng-click="open('lg')"> {{ site.ClientName }} </button> <br /> <b>Facilities:</b> No Data Yet </td> <td>{{ site.Subdomain }}</td> <td> <a href={{ site.URL}}> {{ site.URL}} </a> <br /> <b>Go-live Date: </b> No Data Yet </td> <td>No Data Yet</td> <td>{{site.ChannelPartner}}</td> <td>No Data Yet</td> <td>No Data Yet</td> <td>No Data Yet</td> <td>No Data Yet</td> </tr> <div > <uib-pagination class="pull-right" boundary-link-numbers="true" max-size="maxPaginationSite" boundary-links="true" total-items="resultCount" ng-model="page" ng-change="pageChanged()"></uib-pagination> </div> </tbody>
尝试将div包装在div中,但是div中的控制器:
原文链接:https://www.f2er.com/angularjs/143217.html<div ng-controller="BusinessController"> <tbody> <tr ng-repeat="site in getBusinessSites"> . . . </tbody> </div>
我建议将$scope.getBusinessSites命名为$scope.businessSites以避免混淆:)