angular.module("myApp").controller('projectViewsController', function ($scope, $http,$filter) {
    $scope.listProject = [];
    $scope.currentPage = 1;
    $scope.numPerPage = 3;
    $scope.maxSize = 5;
    $scope.numberOfPage = numberOfPage;
    $scope.dataHasLoaded = false;
    //mới thêm
    $scope.makeEmployee = function () {
        $scope.listProject = [];
        for (i = 1; i <= 100; i++) {
            $scope.listProject.push({text: 'project ' + i, done: false});
        }
    };
    $scope.keyword = "";
    //mới thêm
    $scope.getAll = getAll;
    $scope.getTotalItems = getTotalItems;

    getAll();

    function getTotalItems() {
        return $filter('filter')($scope.listProject, {'name': $scope.keyword}).length;
    }

    $scope.pageChangedIndex = function(){
        console.log($scope.currentPage);
    }

    function numberOfPage() {
        return Math.ceil($scope.listProject.length / $scope.numPerPage);

    };
    function getAll() {
        $http.get("http://localhost:8081/quan-tri/danh-sach-du-an").then(successCallback, errorCallback);

        function successCallback(response) {
            console.log(response.data);
            {
                $scope.listProject = response.data;
            }
        }

        function errorCallback(error) {
            console.log("can't get data!!");
        }
    }
});