In my Angular (8) using NgbModal. parent page, one of component getting the data from http service (java and mysql db) as list. and on submit of modal, it will insert a record in same table of mysql db. now after Modal submit and dismiss, how to refresh/update the component list data with new data.
Parent Component -> opening the modal component
"selectedName" fetch from DB and displaying in parent component.
openEditProfilePage() {
const modalRef = this.modalService.open(EditProfileComponent, { size: 'xl', scrollable: true });
modalRef.componentInstance.selectedName = this.selectedName;
}
Child component get value of selectedName from parent, and in a form update to apend some string and save.
onSave(form: FormGroup) {
if (form.valid) {
this.nameService.editName(form.value).subscribe(
res => {
this.modalService.dismissAll();
},
error => {
this.showError(error);
}
);
}
}
Now in child it will update the name in DB.so after dismissAll, modal/popup will be closed, and same time want to display the updated name, in parent component.