How to pass data through ng-content?

450 Views Asked by At

My goal is to select a piece of HTML in component 2 which should render HTML with data from component 1.

This is the demo pseudo code of my aproach:

Component 1

<div>     
  <ng-content select="[item-template]; context: { $implicit: data}"></ng-content>
</div>      

Component 2

<app-component-1>
  <ng-template item-template let-data>
     <div>{{data.prop1}}</div>
  </ng-template>
</app-component-1>

Hope to have explained my question well. Thanks in advance.

0

There are 0 best solutions below