What is the best way to implement backend pagination using angularJS?

I have a situation where I want to implement back end pagination but, I am not sure about how to do it. I am thinking of a solution where I fetch the total pages (a page is a list of n defined element ) and then make call to the server to fetch 1st, 2nd, 3rd, 4th , .... n-th page and so on. Any suggestions ?

Generally, pagination is done by specifying to the user how many results to display per page, and which page of results he is currently viewing. However, backend storage such as MySQL or Solr typically handle pagination by specifying how many results to display per page, and how many results to skip in the output. I generally use something like the following PHP to get the later (for the backend) out of the former (from the user):

$documentsPerPage = 10;

if ( isset($input['page']) && is_numeric($input['page']) && $input['page']>0 ) { 
    $skip = $documentsPerPage * (intval($input['page'])-1);
} else {
    $skip =0;
}

$sql = "SELECT * FROM someTable LIMIT {$skip}, {$documentsPerPage}";

If you have $count records in the database, here is how to calculate how many pages you have with a simulated floor-up operation:

$totalPages = ($count + $documentsPerPage - 1) % $documentsPerPage;