brantwills/Angular-Paging

DataBinding

Closed this issue · 1 comments

Hi, I'd like to know hoe do you bind your large data to it using angular.
Do you have an example ?
Thanks

Hey narzul1,

When I have large data sets to bind against I usually create some kind of ajax or promise call to the server which returns a specific 'page' of my larger data sets information. I then bind that smaller return to say an ng-repeat or an angular service or model.

It's important to understand we never pass the entire data set down to the client. This directive was designed to help by hooking all the dirty paging client side logic up to your own angular services which hold the data. In short, you simply provide the paging directive three items:

  1. What page you are currently interested in
  2. How many items do you want to show on a page
  3. What is the total number of items in your data set

As an example, instead of dumping the entire data set, we just ask the server for a small set say 1,000 per page. One method, if we are using a database, would be to pass in two parameters to our query. One parameter for the page we are interested in "@pagenumber" and the other for how many rows to display per page "@RowsPerPage" which would be 1,000.

The SQL boils down to something like:
SELECT OFFSET ((@pagenumber - 1) * @RowsPerPage) ROWS FETCH NEXT @RowsPerPage

Which for say page 20 with a 1,000 rows per page then looks like
SELECT OFFSET 19000 ROWS FETCH NEXT 1000


I hope that helps alittle bit,
Thanks again for the question and for checking out the directive