Use Angular + Angular-Ui to implement paging (simple code addition), angularangular-ui
Today, let's take a look at an example that only achieves paging without querying. Let's first look at the effect:
The pagination component in Angular-UI is used. For details about how to use Angular-UI, refer to the bootstrapchapter in https://angular-ui.github.io/bootstrap/( ui-router and so on)
Note:The corresponding js and css must be introduced on the official website to take effect. Do not forget it.
The HTML code is as follows:
<Div class = ""> <table class = "table"> <thead class = "hed"> <tr> <th> Province 1 </th> <th> Province 2 </th> <th> Province 3 </th> <th> Province 4 </th> </tr> </thead> <tbody> <tr ng-repeat =" a in allitem [currentPage-1] "> <td ng-bind =". n "> </td> <td ng-bind =". s "> </td> <td ng-bind =". n "> </td> <td ng-bind =". s "> </td> </tr> </tbody> </table> </div> <div class =" "> <pagination boundary-links =" true "total -items = "totalItems" ng-model = "currentPage" class = "pagination-sm embed-responsive-item" previous-text = "previous Page" next-text = "next page" first -text = "Homepage" last-text = "last page" max-size = "maxSize" rotate = "false" num-pages = "numPages"> </pagination> </ div>
The JS Code is as follows:
$ Scope. currentPage = 1; // initial current page $ scope. maxSize = 3; // a maximum of three pages can be displayed. allitem = []; // store all pages $ http. get ('. /js/test '). success (function (data) {$ scope. addr = data. l; var num = $ scope. addr. length; $ scope. totalItems = num; // total number of data records for (var I = 0; I <num; I ++ = 10) {$ scope. allitem. push ($ scope. addr. slice (I, I + 10)} // This method divides an array into multiple arrays and places them in a large array, store 10 data entries per array [because the component defaults to 10 data entries per page]. If there are 41 data entries, we will divide them into 5 pages });
The test. json In the Js folder stores the Chinese address JSon data source for testing.
========================================================== ==========================================================
PS: The above version is 15 years old. Now upload the latest version as an example. In fact, it is an example on the official website. In view of the fact that some babies won't watch FQ, They won it;
Click here to download
Summary
The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message. Thank you for your support.