Угловое повторное использование ng-шаблона между проектами - PullRequest
0 голосов
/ 10 мая 2018

Когда я нахожусь в child.component, как я могу повторно использовать parent.component ng-template?Я хотел бы повторно использовать весь ng-шаблон attachmentTemplate, поэтому мне не нужно снова создавать дублирующий код для вложения в child.component.Заранее благодарю.

parent.component.html

<ng-template #attachmentTemplate let-typeId="typeId">   
   <div>Attachments</div>
   <p>{{typeId}}</p>
</ng-template>
<ng-container *ngTemplateOutlet="attachmentTemplate; context:{typeId: '2'}"></ng-container>

child.component.html

<ng-container *ngTemplateOutlet="attachmentTemplate; context:{typeId: '2'}"></ng-container>
...