I'm using NgbModal from @ng-bootstrap to open modal windows from an Angular 6 application. In one of these modals, I'd like a button click to close the modal and activate a function in the parent/launching component. How can I do that?
I know that with ordinary child and parent components you can emit an event which is caught by the parent component (see this solution here). Is there something analogous I can do with my modal setup? If not, what's the best approach here?
Current code in the parent (simplified):
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ModalComponent } from "...";
@Component ( {...} )
export class ParentComponent {
...
constructor(private modalService: NgbModal) {}
...
showModal(i:InputObject) {
const modalRef = this.modalService.open(ModalCompoenent);
modalRef.componentInstance.i = i;
}
}