I have a component called department where I create a department using a modal dialog as shown below:
department.component
openModal(data) {
//code omitted for simplicity
this.modalService.showMOdal();
this.create();
}
create() {
//code omitted for simplicity
}
employee.component
createDepartment() {
//???
}
On the other hand, I have another component called employee and I need to create a departmet by calling the open dialog and create methods in the department component.
What is the proper way to create department from employee component? Should I implement openModal() and create() methods in employee component as well? Or should I call the methods that are already defined in department component? I think it sould be better to use already existing methods and components in order to avoid from repetition.
Any example approach for this scenario?