How pass data from ModalService into component

后端 未结 5 788
被撕碎了的回忆
被撕碎了的回忆 2021-01-23 05:09

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(ModalContentCompo         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-23 05:17

    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';
        }
    ...
    

提交回复
热议问题