问题
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