angular - 使用子组件实例作为角度的道具
问题描述
我创建了一个basicModalComponent
,它负责基本操作,例如关闭、提交、显示页眉和页脚。将简单的消息放在我的模态正文中效果很好。
但我希望能够传递一个子组件来管理我的身体,如下所示:
this.modal = await this.modalController.create({
component: BasicModalComponent,
componentProps: {
title: `Share!`,
body: ChildContentViewComponent,
bodyProps: {... some data here},
// body: new ChildContentViewComponent({some data here}),
confirm: this.onConfirmDeleteAction,
cancelButton: true
}
});
这将处理一些更复杂的逻辑。
现在,这就是身体在我的basicModalComponent
<p class="modal-body text-center scrollable scrollbar-hidden">
{{body}}
</p>
显然,它与字符串文本一起工作得很好,但现在我想在这里放一个子组件。
结果如下:
如果可能的话,在实例化期间带有来自父级的数据
但我不知道这是否可能或一个好的模式。我认为这是可能的,因为这是modalController
我实际上正在做的事情,BasicModalComponent
但我仍然不确定这种模式。我看过继承和组合,但也没有设法让它工作。
你有什么想法/提示吗?提前致谢。
解决方案
// Create instance with ProfileComponent as child component
let profileModal = this.modalCtrl.create(ProfileComponent , { userId: 8675309 });
profileModal.present();
推荐阅读
- loopbackjs - PM2 不在 DigitalOcean Ubuntu 服务器上启动 Loopback 4 应用程序
- google-cloud-platform - 尝试从 Google Drive 电子表格访问 BigQuery 表源时出现 Google Data Studio 错误
- printing - 如何为大问题打印纸浆中的特定约束
- linux - 在日志翻转的情况下,如何在多个日志的开始和结束时间之间执行“sed”操作。?
- powershell - 将 IPAddress 数组转换为 HTML
- c - 如何自定义 C printf 函数以自动添加消息日志?
- javascript - AngularJS 动态地改变一个选择的 CSS 类
- javascript - 将嵌套数组中的特定键更改为javascript中的对象
- amazon-web-services - Airflow 1.1.10 远程 S3 日志
- tensorflow - 设置卷积层的过滤器权重