In angular 1, how can I paginate my ng-repeats?

后端 未结 2 879
独厮守ぢ
独厮守ぢ 2021-01-07 15:04

I am currently limiting my ng-repeat to 5 using a filter, but I\'m wondering how I can paginate the data.

<
2条回答
  •  猫巷女王i
    2021-01-07 15:50

    Yes, there's a nice directive for AngularJS called dirPagination. You can paginate tables and almost everything that you need.

    Look at it on Github and if you want to see a demo, Plunker.

    After you downloaded the Javascript and template Html files, you need to do some basic steps:

    1. In your Javascript file, put:

      $scope.currentPage = 1; // The page that should start the pagination.
      $scope.pageSize = 5; // The limit of items per page.

    2. Change your div:

      to

    3. Add the pagination controls in your html file (Be sure to set the correct url for the template).

    UPDATE

    I made a plnkr to demonstrate how it would look in your case. Please, take a look.

提交回复
热议问题