I have create a simple table wrapper component in Angular. In wrapper component in 1st column I wanted to show custom template.
My main challange is here to write all the template of that column in parent component only.
Means Whatever template I am giving in parent, at that particular row that template should be shown.
I tried something like this
2
Answers
You can use Angular’s
ngTemplateOutlet
.Here’s an example of how you can modify your code:
app.component.ts
)table-wrapper.component.ts
):You did everything correctly in your code sample, all you need is to add a
ng-template
to your html file and it will work fine.With your row code:
Adding this will display the item name:
Working example
If you need anything more complex, I would advise you build a service to share data between this and the parent component.