angular - 如何将数据传递给 Angular ng-bootstrap 模态以进行绑定(bind)

标签 angular modal-dialog

场景:

  • ChildComponent - 有很多 ngModel 绑定(bind)元素。
<input [(ngModel)]="TryToPassDataModel.name">;
  • 父组件 -
btn.onClick = function() {
  this.bsModalRef =
    this.modalService.open(ChildComponent, TryToPassDataModel);
}

这在 ngx-bootstrap 中有效,但如何在 nb-bootstrap 中实现呢? (看起来就是这么简单的想法)

最佳答案

您似乎没有正确使用 API。该插件期望参数作为@Input() 传递。这样的事情会起作用:

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

确保在 ModalContent 组件中为模型添加 @Input!

有关更多信息,请参阅文档:https://ng-bootstrap.github.io/#/components/modal/examples

关于angular - 如何将数据传递给 Angular ng-bootstrap 模态以进行绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48698665/

相关文章:

asp.net-mvc-3 - 关闭包含 ASP MVC Ajax 表单的模式窗口

css - 动态更改模态对话框 css 样式

javascript - 在页面上多次使用时 iframe 的问题

javascript - 利用 Angular 中的导入函数进行插值

重新订阅时出现 Angular ObjectUnsubscribedError

knockout.js - Durandal 2.0 自定义对话框

iOS 6 : Parent modal's modalPresentationStyle ignored after rotation

angular - 将 formControlName 传递给 Angular 组件

javascript - 在 Angular2 指令中注入(inject) Angular1 服务

在 Azure 中托管时,Angular 应用程序刷新不起作用