Suppose I have the following component (let's call it "MyModalComponent")
MyModalComponent
<div class="my-modal">
<div class="my-modal-header">
<ng-content select="modal-title></ng-content>
</div>
<div class="my-modal-body">
<ng-content></ng-content>
</div>
</div>
When I use it like this, it works perfectly;
<my-modal>
<h1 modal-title>I am a modal</h1>
<div>
And this is my body!
</div>
</my-modal>
- The title is rendered within the
<div class="my-modal-header">
div - The rest of the content goes into the
<div class="my-modal-body">
div
However, if I would wrap my html into a different component, the selector projection doesn't work anymore.
MyModalContentComponent
<h1 modal-title>I am a modal</h1>
<div>
And this is my body!
</div>
<my-modal>
<my-modal-content></my-modal-content>
</my-modal>
Now all the html code is rendered into the "fallback" <ng-content></ng-content>
slot of the MyModalComponent (so, inside the <div class="my-modal-body">
div).
Selectors don't seem to work anymore in this case.
Is this "by design", or rather, how can I make sure it will continue working just like it would if you would place the html markup directly in the MyModalComponent?