how to pass data to Angular ng-bootstrap modal for binding

隐身守侯 提交于 2019-12-10 15:06:32

问题


Scenario:

  • ChildComponent - having a lot ngModel binding elements. ;
  • ParentComponent - btn.onClick = function(){ this.bsModalRef = this.modalService.open(ChildComponent, TryToPassDataModel);} This works in ngx-bootstrap, but how to implement this in nb-bootstrap? (it looks like such a simple idea)

回答1:


Looks like you're not using the API properly. The plugin expects the params to be passed as @Input(). Something like this would work :

const modalRef = this.modalService.open(NgbdModalContent);
modalRef.componentInstance.name = 'World';

Make sure you add a @Input for your model in ModalContent component!

See the doc for more info : https://ng-bootstrap.github.io/#/components/modal/examples



来源:https://stackoverflow.com/questions/48698665/how-to-pass-data-to-angular-ng-bootstrap-modal-for-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!