I am currently working on implementing a modal with Angular by following a tutorial on the ng-bootstrap website ( - in the "Components as content" section). However, I am facing a challenge where I want the component displayed in the modal to retain its state even after it is closed and reopened.
To illustrate this issue, I have created a simple example on Plunker: http://plnkr.co/edit/EJyZ6nF5WVAS9bvQycQe?p=preview
My goal is to have the text "Hello, A!" displayed when calling open() after calling openA(), but unfortunately, the state is not being preserved.
openA() {
const modalRef = this.modalService.open(NgbdModalContent);
modalRef.componentInstance.name = 'A';
}
openB() {
const modalRef = this.modalService.open(NgbdModalContent);
modalRef.componentInstance.name = 'B';
}
open() {
const modalRef = this.modalService.open(NgbdModalContent);
}
How can I achieve this with the minimum setup? Are there any specific Angular documentation resources you recommend for better understanding of the situation?