I'm trying to use ngx-bootstrap-modal to pass data from a modal service into a modal component. The examples show this:
this.modalService.show(ModalContentComponent, {initialState});
But it doesn't show how the ModalContentComponent
actually consumes that state. I've played around in a debugger and I never see my component getting that data.
How do I access it from the component?
You can also use the BsModalRef content
Like
my-modal.component.ts
export class MyModalComponent {
public myContent;
constructor(){}
}
calling your modal from some other component
import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
...
public modalRef: BsModalRef;
constructor(public modalService: BsModalService){}
public openModal() {
this.modalRef = this.modalService.show(MyModalComponent);
this.modalRef.content.myContent= 'My Modal Content';
}
...