A paging instruction based on ANGULARJS and layer __js

Source: Internet
Author: User
HTML code:
<table style= "width:100%" >
			<tr>
				<td> total: <span style= "color: #12bdce; font-weight:bold;" >{{total_pages}}</span> page <span style= "color: #12bdce; font-weight:bold;" >{{total}}</span> Bar </td>
				<td style= "text-align:right;" >
					<div layer-pages id= "Page_bar"  data-options= "url: ' busmaintenanceitem/query.do ', callback: ' Getpagedatalist ', Pagecolor: ' #12bdce ', pageSize: ' Ten ', Groups: ' 3 ', Isskip:false ' style= ' margin-right:0px; ></div>
				</td>
			</tr>
		</table>

JS callback method:

Gets the current page data information (for paging instruction callback)
	$scope. getpagedatalist = function (pageInfo) {
		 $scope. maintenanceitemlist = pageinfo.data_list;//data
		 $scope. Total = pageinfo.total;//number
		 $scope. total_pages = pageinfo.total_pages;// Total number of bars
	}

Specific paging instruction code

App.directive ("Layerpages", [' $rootScope ', ' $compile ', ' Page ', function ($rootScope, $compile, Page) {return {
	    	   Restrict: ' AE ', link:function (scope, Elem, attrs) {var page_id = attrs.id; var options =eval (' [{' +] + (Attrs.options | | ') + '}] ' [0] var url = options.url;//Data interface var page_color =options.pagecolor;//color var page_g roups = options.groups;//continuous pages var page_size = options.pagesize;//per-page display bars var page_is_skip = options.is skip;//whether to turn on page-skipping var callbackfun = scope. $eval (options.callback);//callback function if (!callbackfun | |!typeof (CALLBA
                   Ckfun) = = ' function ') {return;
	    	   
	    	   } var page_index = 0;
	    	   var param = {};
	    	   Param._pageindex = Page_index;
	    	   Param._pagesize = page_size;
	    		   Page.ajaxpost (URL, param, function (resp) {var data_list = resp.data.rows; var total = resp.data.total;//Gross page_pages = Math.ceil (total% page_size = 0? total/pagesize:total/page_size);
    			   var pageInfo = {};
    			   Pageinfo.data_list = data_list;
    			   Pageinfo.total = total;
    			   Pageinfo.total_pages = total_pages; Callbackfun (PageInfo);
					     Callback Laypage ({cont:page_id, pages:total_pages,//gets the total number of pages Skin:page_color,
					     Skip:page_is_skip,//whether to open the jump page prev:false,//If not displayed, set false to Next:false,//If not displayed, set false
					     Groups:page_groups,///Continuous page curr:1,//initialization of current pages jump:function (Obj,first) {//Trigger paging callback /*obj is an object type.
					     Includes all the configuration information for pagination. First a Boolean class that detects whether the page is initially loaded. Very useful to avoid infinite refreshes.
							*/if (!first) {param._pageindex = obj.curr-1;
								Page.ajaxpost (URL, param, function (resp) {var data_list = resp.data.rows;
								Pageinfo.data_list = data_list;
						   Callbackfun (pageInfo);//callback});
}
					    }
					})			    }); 
		   }
   		}
}]);
Effect Chart:

Related Article

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.