Use Angular + Angular-Ui to implement paging (simple code addition), angularangular-ui

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.