How pass data from ModalService into component

后端 未结 5 849
被撕碎了的回忆
被撕碎了的回忆 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:34

    Here, in parentComponent where initialState data is being sent using config param in modalService.show:

    const initialState = {
          data: "Test Data"
        };
        this.modalService.show(ModalContentComponent, {initialState});
    

    Access the data in ModalContentComponent by simply defining exact same named variable, i.e., data: string; You will be able to access value of data in ModalContentComponent.html and ModalContentComponent.ts.

提交回复
热议问题