This is how I implemented it which I hope will be helpful for you as a reference.
JS:
$scope.RegionPage = 1;
$scope.RegionRow = 10;
$scope.RegionRows = [5, 10, 20];
$scope.GetAttributesByRegion = function (regionFrwdPageButtonClick, regionBckPageButtonClick) {
if (regionFrwdPageButtonClick) {
if (($scope.RegionPage + 1) <= $scope.RegionTotalPages) {
$scope.RegionPage = $scope.RegionPage + 1;
}
}
if (regionBckPageButtonClick) {
if ($scope.RegionPage <= 0) {
$scope.RegionPage = 1;
} if ($scope.RegionPage > 1) {
$scope.RegionPage = $scope.RegionPage - 1;
}
}
//get all regions
$http({ method: 'GET', url: '/Admin/GetAttributesByRegion', params: { page: $scope.RegionPage, rows: $scope.RegionRow } }).success(function (data, status) {
$scope.Regions = data;
$scope.RegionTotalRecords = 0;
if (data != null && data != '' && JSON.stringify(data) != '[]') {
$scope.RegionTotalPages = parseInt(Math.ceil(data[0].TotalRecords / $scope.RegionRow));
$scope.RegionPages = new Array();
for (i = 1; i <= $scope.RegionTotalPages; i++) {
$scope.RegionPages[i] = i;
}
} else {
$scope.RegionTotalPages = 0;
$scope.RegionPages = null;
}
});
};
HTML:
<div style="overflow-x: scroll; padding-right: 1px;">
<table class="table table-condensed" style="font-size: 85%; min-width: 650px;">
<thead>
<tr>
<th>Region</th>
<th>State</th>
<th>Neighborhoods</th>
<th>Locations</th>
<th>Revenue</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="region in Regions">
<td>{{region.RegionName}}</td>
<td>{{region.State}}</td>
<td>{{region.NeigborhoodCount}}</td>
<td>{{region.LocationCount}}</td>
<td>{{region.Revenue}}</td>
<td>
<span class="pull-right">
<a href="#regionDetailsModal" data-toggle="modal">Details</a> /
<!-- TODO Aamir Malcolm -- Please integrate link below -->
<a href="#addNeighborhoodModal" data-toggle="modal">Add a Neighborhood</a>
</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="row-fluid">
<a href="#addRegionModal" class="btn btn-pinkes span3" style="margin-top: 15px;" data-toggle="modal"><i class="icon-plus icon-white"></i> Add new</a>
<div class="span9 drmc" style="font-size: 85%;">
<button ng-click="GetAttributesByRegion(false,true)" class="btn btn-mini" id="btnBackwardTop" type="button"><i class="icon-arrow-left"></i></button>
Page
<select style="width: auto; margin-top: 10px;" ng-change="GetAttributesByRegion(false,false)" ng-model="RegionPage">
<option ng-repeat="regionPage in RegionPages">{{regionPage}}</option>
</select>
of {{RegionTotalPages}}
<button ng-click="GetAttributesByRegion(true,false)" class="btn btn-mini" id="btnForwardTop" type="button"><i class="icon-arrow-right"></i></button>
<select style="width: auto; margin-left: 5px; margin-top: 10px;" ng-change="GetAttributesByRegion(false,false)" ng-model="RegionRow">
<option ng-repeat="regionRow in RegionRows">{{regionRow}}</option>
</select>
</div>
</div>