[英]Angular - How to reuse data in manually nested components
我有兩個Angular組件, checklist-page
和checklist
。 checklist-page
從后端下載數據
我想用checklist
組件多次內部checklist-page
組件。
我想在checklist
組件中使用checklist-page
的下載數據。
不同之處在於,我無法選擇基本的父子組件嵌套方式,因為我想以這種方式自定義地設置每個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>
簡而言之,我不知道checklist-page
模板的內容是什么,它可能有所不同。
在這種情況下,如何將數據從checklist-page
傳遞到checklist
?
您可以使用動態組件加載器https://angular.io/guide/dynamic-component-loader 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.