Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng重复中的Angularjs分页_Javascript_Jquery_Angularjs - Fatal编程技术网

Javascript ng重复中的Angularjs分页

Javascript ng重复中的Angularjs分页,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,在我的控制器中,我有以下从数据库获取数据的代码 $scope.noOfPages = 0; $scope.currentPage = 1; $scope.maxSize = 5; $scope.tickets = TicRepository.getTics.query({ id: $routeParams.t_id }, function (data) { $scope.tickets = data.items; $scope.noOfPage

在我的控制器中,我有以下从数据库获取数据的代码

 $scope.noOfPages = 0;
    $scope.currentPage = 1;
    $scope.maxSize = 5;
 $scope.tickets = TicRepository.getTics.query({ id: $routeParams.t_id }, function (data) {
        $scope.tickets = data.items;
        $scope.noOfPages = data.totalPages,
        $scope.currentPage = data.pages;
    });
在我的html中,我有

 <div>
    div>
        {{noOfPages}} &nbsp; {{currentPage}} &nbsp; {{maxSize}}
        <pagination num-pages="noOfPages" current-page="currentPage"></pagination>
    </div>
     <div ng-repeat="tics in tickets " >
          ................
     </div>
  </div>

div>
{{noOfPages}{{currentPage}{{{maxSize}}
................
我得到的数据很好,但分页不起作用。在分页按钮中,它只显示一页并列出所有项目。请让我知道如何解决这个问题。
谢谢

这是我如何实现它的,希望能对您有所帮助,作为参考

JS:

$scope.RegionPage=1;
$scope.RegionRow=10;
$scope.RegionRows=[5,10,20];
$scope.GetAttributesByRegion=函数(regionFrwdPageButtonClick,regionBckPageButtonClick){
如果(区域FRWDPAGEBUTTONCLICK){
如果($scope.RegionPage+1)

这是我如何实现它的,我希望这将有助于您作为参考

JS:

$scope.RegionPage=1;
$scope.RegionRow=10;
$scope.RegionRows=[5,10,20];
$scope.GetAttributesByRegion=函数(regionFrwdPageButtonClick,regionBckPageButtonClick){
如果(区域FRWDPAGEBUTTONCLICK){
如果($scope.RegionPage+1)

看起来您正在使用。
分页
指令跟踪当前页面,但您仍然需要筛选数组。一种解决方案是在数组的子集上重复
ng

<pagination ng-model="currentPage" total-items="tickets.length" items-per-page="5"></pagination>
<div class="alert alert-info" ng-repeat="tic in paged.tickets">
  {{tic}}
</div>
下面是一个工作演示:


此相关问题中还介绍了一些其他(更复杂的)选项:

看起来您正在使用。
分页
指令跟踪当前页面,但您仍然需要筛选数组。一种解决方案是在数组的子集上重复
ng

<pagination ng-model="currentPage" total-items="tickets.length" items-per-page="5"></pagination>
<div class="alert alert-info" ng-repeat="tic in paged.tickets">
  {{tic}}
</div>
下面是一个工作演示:


其他一些(更复杂的)选项包含在这个相关问题中:

你能发布小提琴或普朗克吗?没有看到你的指令也很难说。你能发布小提琴或普朗克吗?没有看到你的指令也很难说。
<pagination ng-model="currentPage" total-items="tickets.length" items-per-page="5"></pagination>
<div class="alert alert-info" ng-repeat="tic in paged.tickets">
  {{tic}}
</div>
$scope.$watch('currentPage', function() {
  var begin = ($scope.currentPage - 1) * $scope.itemsPerPage;
  var end = begin + $scope.itemsPerPage;

  $scope.paged = {
    tickets: $scope.tickets.slice(begin, end)
  }
});