Is it possible to insert a component into another parent component and pass data to the child component from the parent component?
in user.html
<app-table>
<app-detail></app-detail>
</app-table>
in table.html
<div *ngFor="let item of items">
<ng-content [item]="item"></ng-content> (its my problem)
</div>

You can use ngTemplateOutlet:
https://angular.io/api/common/NgTemplateOutlet
<app-user>
<app-table [cardTemplate]="pCard"></app-detail>
</app-user>
<ng-template let-record #pCard>
<div class="card">
</div>
</ng-template>
Table component:
<div class="nsCard">
<ng-container *ngTemplateOutlet="cardTemplate; context:{$implicit: record}"></ng-container>
</div>
And inside table component:
@Input() cardTemplate: TemplateRef<any>;
Actually it is more advanced form of ng-template, that provides ability to pass data and many others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With