var app = angular.module("pagingtable",['bw.paging']); app.controller('activityTableCtrl', function($scope, $http, $interval, $location, $timeout, $rootScope) { $scope.currentPage = 1; $scope.totalItems = 0; $scope.pa = 10; $scope.pageSize = '100'; $scope.searchText = ''; getData(); $scope.menu = function(id) { location.href = id; }; function getData() { $http.get('/ajax/json/index.php?page=' + $scope.currentPage + '&size=' + $scope.pageSize + '&url=' + $scope.mc + '&search=' + $scope.searchText + '&pa=' + $scope.pa) .success(function(data) { $scope.title = data.title; $scope.activity = []; $scope.totalItems = data.totalCount; $scope.startItem = ($scope.currentPage - 1) * $scope.pageSize + 1; $scope.endItem = $scope.currentPage * $scope.pageSize; if ($scope.endItem > $scope.totalCount) {$scope.endItem = $scope.totalCount;} angular.forEach(data.Biodata, function(temp){ $scope.activity.push(temp); }); }); } $scope.pageChanged = function(text, page, pageSize, total) { $scope.currentPage = page; getData(); } $scope.paChanged = function() { $scope.pageSize = $scope.pa; $scope.currentPage = 1; getData(); } $scope.pageSizeChanged = function() { $scope.currentPage = 1; getData(); } $scope.searchTextChanged = function() { $scope.currentPage = 1; getData(); } $scope.openModal = function(){ var modal_popup = angular.element('#och'); modal_popup.modal('show'); }; $scope.submitForm = function(){ $http({ method:"POST", url:"/ajax/json/index.php?e=add", data:{'delete_id':$scope.delete_id} }).success(function(data){ if(data.error) { $scope.success = false; $scope.error = true; $scope.errorMessage = data.error; } else { $scope.delete_id = '0'; $scope.success = true $scope.error = false; $scope.successMessage = data.message; $scope.form_data = {}; $scope.closeModal(); $scope.currentPage = 1; getData(); } }); }; $scope.och = function(id){ var modal_popup = angular.element('#och'); modal_popup.modal('show'); $scope.modal_title = 'Продукт продан'; $scope.modal_ob = 'Вы действительно подтверждаете?'; $scope.delete_id = id; }; $scope.closeModal = function(){ var modal_popup = angular.element('#och'); modal_popup.modal('hide'); }; });