/**
 * 
 */
angular.module("myApp",[]).controller("tintucController", function($scope, $http,$window) {
	console.log("Tin tức controller");

	$scope.emp=   {
		"username": "",
		"password": "",
		"firstName": "",
		"lastName": "",
		"emailAddress": "",
		"phoneNumber": "",
		"homeTown": "",
		"education": ""
	};



	$scope.save = save;

	function save(){
		console.log($scope.emp);
		$http({
			method : 'POST',
			url : "http://localhost:8081/list_employee/",
			data: $scope.emp
		}).then(function successCallback(response) {
			console.log(response);
			// $window.location.href ='http://localhost:8081/#/tintuc';
		}, function errorCallback(response) {
			console.log(response)
		});
	}
	$scope.update = update;
	 function update(employee){
      $scope.employee = employee;
       list_employee();
     }
    $scope.deleteEmployee = function (employee) {
		$http({
			method : 'DELETE',
			url : 'http://localhost:8081/deleteEmployee/' + employee.id
		}).then(_success, _error);
	}


	$http({
		method : 'GET',
		url : "http://localhost:8081/list_employee/",
	}).then(function successCallback(response) {
		console.log(response)
		$scope.employess=response.data;
	}, function errorCallback(response) {
		console.log(response)
	});
});