add functionality to delete employee button (#11)
Reviewed-on: #11 Reviewed-by: Hernd Beidemann <huydw@proton.me>
This commit is contained in:
34
src/app/delete-employee/delete-employee.component.ts
Normal file
34
src/app/delete-employee/delete-employee.component.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import {Component, Inject, inject} from '@angular/core';
|
||||
import {Employee} from "../Employee";
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
MatDialogContent,
|
||||
MatDialogTitle
|
||||
} from "@angular/material/dialog";
|
||||
import {MatButton} from "@angular/material/button";
|
||||
import EmployeeApiService from "../services/employee-api.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-delete-employee',
|
||||
imports: [
|
||||
MatDialogContent,
|
||||
MatDialogTitle,
|
||||
MatDialogActions,
|
||||
MatButton,
|
||||
MatDialogClose
|
||||
],
|
||||
templateUrl: './delete-employee.component.html',
|
||||
standalone: true,
|
||||
styleUrl: './delete-employee.component.css'
|
||||
})
|
||||
export class DeleteEmployeeComponent {
|
||||
private apiService: EmployeeApiService = inject(EmployeeApiService);
|
||||
|
||||
protected employee: Employee = inject(MAT_DIALOG_DATA);
|
||||
|
||||
deleteEmployee(id: number) {
|
||||
this.apiService.deleteById(id).subscribe();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user