Angularjs Sub-page

Source: Internet
Author: User

<p> forms </p><!--new Bootstrap core CSS file--><div id="Divmain"><tableclass="Table Table-bordered"><tbody><tr><td>{{item.appName}}</td><td>{{item.linkObjectName}}</td> <td>{{item.linkaddress}}</td><td><buttonclass="Btn_orange"> Generate two-dimensional code </button></td><td><buttonclass="Btn_orange"> Delete </button></td></tr></tbody></table><ulclass="pagination"><li><a> <span> Previous </span> </a></li><li><a>{{page}}</a> </li><li><a> <span> Next </span> </a></li></ul></div>< Script Type="Text/javascript"Src="Angular.js"></script><script type="Text/javascript">//<! [Cdata[    varApp = Angular.module ("myApp", []); App.controller ("Myctrl", function ($scope, $http) {$http.Get("Service.js"). Then (function (response) {//Data Source$scope. Data =response.data.records;//total number of pages$scope. pageSize =5; $scope. Pages= Math.ceil ($scope. data.length/$scope. pageSize);//Number of pages$scope. newpages = $scope. Pages >5?5: $scope. pages; $scope. PageList= []; $scope. Selpage=1;//set up a tabular data source (paging)$scope. SetData =function () {$scope. Items= $scope. Data.slice ($scope. PageSize * ($scope. Selpage-1)), ($scope. Selpage * $scope. pageSize));//filter out the current page display data by the current number of pages} $scope. Items= $scope. Data.slice (0, $scope. pageSize);//the array to repeat for paging             for(vari =0; I < $scope. Newpages; i++) {$scope. Pagelist.push (i+1); }//Prints the index of the currently selected page$scope. Selectpage =function (page) {//cannot be less than 1 greater than maximum                if(Page <1|| Page > $scope. Pages)return;//display up to 5 of pages                if(Page >2) {//because only 5 pages are displayed, more than 2 pages start the paging conversion                    varNewpagelist = [];  for(vari = (Page-3) ; I < (page +2) > $scope. pages? $scope. Pages: (page +2)) ; i++) {Newpagelist.push (i+1); } $scope. pagelist=newpagelist; } $scope. selpage=page;                $scope. SetData ();                $scope. Isactivepage (page); Console.log ("selected page:"+page); };//set the currently selected page style$scope. Isactivepage =function (page) {return$scope. Selpage = =page; };//Previous Page$scope. Previous =function () {$scope. Selectpage ($scope. Selpage-1); }//Next Page$scope. Next =function () {$scope. Selectpage ($scope. Selpage+1);        };    }); })//]]></script>

Angularjs Sub-page

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.