I have 2 components, a parent and a child. The parent contains the child and uses it to wrap some content and add a title to it. The child component uses transclusion to achieve that.
The parent template looks like:
<div class="parent">
<child [title]="componentTitle" class="child">
<p>some content</p>
</child>
</div>
The child template looks like:
<div class="child">
<h2 class="title">{{title}}</h2>
<ng-content></ng-content>
</div>
When I try to control the styles using the parent component's CSS, I can deal with all the transcluded content simply enough:
.child p {
background-color: blue;
}
However, I'm unable to get to the title element. In other words, the following rule does not work:
.child h2.title {
background-color: red;
}
Since parent is the host of child, using :host
doesn't work.
Any suggestions ?