[英]Angular - How to reuse data in manually nested components
I have two Angular components, checklist-page
and checklist
. 我有两个Angular组件,
checklist-page
和checklist
。 checklist-page
downloads the data from the backend checklist-page
从后端下载数据
I would like to use the checklist
component multiple times inside the checklist-page
component. 我想用
checklist
组件多次内部checklist-page
组件。
I'd like to use the downloaded data of checklist-page
in checklist
components. 我想在
checklist
组件中使用checklist-page
的下载数据。
The twist is, I can't choose the basic parent-child component nesting way, because I would like to customly parameterize each checklist
instances this way: 不同之处在于,我无法选择基本的父子组件嵌套方式,因为我想以这种方式自定义地设置每个
checklist
实例的参数:
<checklist-page [type]='locations'>
<checklist [checklistData]="parentComponentData" [filter]='visited'>
<checklist [checklistData]="parentComponentData" [filter]='remaining'>
<checklist [checklistData]="parentComponentData" [filter]='visited' [userId]=123>
<checklist [checklistData]="parentComponentData" [filter]='visited' [userId]=234>
<checklist [checklistData]="parentComponentData" [filter]='remaining' [userId]=456>
<checklist [checklistData]="parentComponentData" [filter]='remaining' [userId]=456>
.
.
.
</checklist-page>
So, in short, I don't know exactly what is the content of the checklist-page
template, it can be vary. 简而言之,我不知道
checklist-page
模板的内容是什么,它可能有所不同。
How can I pass the data from checklist-page
to checklist
in this scenario? 在这种情况下,如何将数据从
checklist-page
传递到checklist
?
您可以使用动态组件加载器https://angular.io/guide/dynamic-component-loader 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.