<div ng-app=
"DemoApp"
ng-controller=
"DemoController"
>
<table
class
=
"table table-striped"
>
<thead>
<tr>
<td>ID</td>
<td>FirstName</td>
<td>LastName</td>
<td>Status</td>
<td>Address</td>
</tr>
</thead>
<tbody>
<tr ng-repeat=
"emp in persons"
>
<td>{{emp.ID}}</td>
<td>{{emp.FirstName}}</td>
<td>{{emp.LastName}}</td>
<td>{{emp.Status}}</td>
<td>{{emp.Address}}</td>
</tr>
</tbody>
</table>
<tm-pagination conf=
"paginationConf"
></tm-pagination>
</div>
<script type=
"text/javascript"
>
var
app = angular.module(
'DemoApp'
, [
'tm.pagination'
]);
app.controller(
'DemoController'
, [
'$scope'
,
'BusinessService'
,
function
($scope, BusinessService) {
var
GetAllEmployee =
function
() {
var
postData = {
pageIndex: $scope.paginationConf.currentPage,
pageSize: $scope.paginationConf.itemsPerPage
}
BusinessService.list(postData).success(
function
(response) {
$scope.paginationConf.totalItems = response.count;
$scope.persons = response.items;
});
}
$scope.paginationConf = {
currentPage: 1,
itemsPerPage: 5
};
$scope.$watch(
'paginationConf.currentPage + paginationConf.itemsPerPage'
, GetAllEmployee);
}]);
app.factory(
'BusinessService'
, [
'$http'
,
function
($http) {
var
list =
function
(postData) {
return
$http.post(
'/Employee/GetAllEmployee'
, postData);
}
return
{
list:
function
(postData) {
return
list(postData);
}
}
}]);
</script>