Labsheet 10
Labsheet 10
Labsheet 10
Employeedetails.html
<!DOCTYPE html>
<html lang="en" ng-app="employeeManagementApp">
<head>
<meta charset="UTF-8">
<title>Employee Management System</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
<script src="Employeedetails.js"></script>
</head>
<body ng-controller="EmployeeController as vm">
<h1>Employee Management System</h1>
<label for="name">Name:</label>
<input type="text" id="name" ng-model="vm.newEmployee.name" required><br>
<label for="department">Department:</label>
<input type="text" id="department" ng-model="vm.newEmployee.department" required><br>
<label for="position">Position:</label>
<input type="text" id="position" ng-model="vm.newEmployee.position" required><br>
Employeedetails.js
angular.module('employeeManagementApp', [])
.controller('EmployeeController', function() {
var vm = this;
vm.employees = [
{ employeeId: '1', name: 'John Doe', department: 'HR', position: 'Manager' },
{ employeeId: '2', name: 'Alice Smith', department: 'Finance', position: 'Accountant' },
{ employeeId: '3', name: 'Bob Johnson', department: 'IT', position: 'Developer' }
];
vm.newEmployee = {};
vm.addEmployee = function() {
vm.employees.push(vm.newEmployee);
vm.newEmployee = {};
};
vm.editEmployee = function(employee) {
vm.newEmployee = angular.copy(employee);
};
vm.deleteEmployee = function(employee) {
var index = vm.employees.indexOf(employee);
vm.employees.splice(index, 1);
};
});