加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – ng-repeat在更改数组时不更新

发布时间:2020-12-17 07:49:10 所属栏目:安全 来源:网络整理
导读:我有一个ng-repeat,它在更改正在使用的数组中时没有更新.我已经研究了很长一段时间但似乎没有任何工作.最初,当页面加载时,ng-repeat显示数据集的第一页,在获取新数据(下一页)并使用此数据设置该数组时,ng-repeat没有注意到更改并且从不填充更新的数组.如果有
我有一个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中的控制器:
<div ng-controller="BusinessController">
    <tbody>   
        <tr ng-repeat="site in getBusinessSites">
        .
        .
        .
    </tbody>
</div>

我建议将$scope.getBusinessSites命名为$scope.businessSites以避免混淆:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读