Reputation: 6247
I'm trying to insert html into a child component. Basically something like this:
<custom-container><p>Parnet content</p></custom-container>
I can find references for passing data to child component but not able to find how to pass actual html inside my selector?
Upvotes: 10
Views: 19902
Reputation: 6247
ng-content tag can be used in the template of the child component. That tag will take in anything that you put in between your component selector.
Upvotes: 1
Reputation: 353
You can also use <ng-content>
with select
attribute
Parent Component:
<child-component>
<div sample>Content form parent</div>
</child-component>
Child Component:
something..
<ng-content select="[sample]"></ng-content>
some more...
Output:
something..
<div>Content from parent</div>
some more...
More details here
Upvotes: 22