I have an outer component (blue-green) featuring some flexbox toolbars with a bunch of my own ui-button buttons. And an inner component, mostly doing its thing in the brown area (as you would expect).
However, depending on the inner component (there are several ones what are switched forth and back), a few more contextual buttons must be inserted in that top/bottom bar.
(CSS tricks with absolute positioning stuff on the outside are not an option, depending on size and convenience the outer toolbars can vary pretty much in position, size and so on...)
Now my question is:
Can I somehow pass in a reference to some placeholder (black square brackets) (just like regular content projection/transclusion), and have them filled by content coming from the child component?
With something like ngTemplate[Outlet] perhaps? And/or using @Output?
I want to “pass upwards” more than plain text or simple <b>rich</b> <i>html</i> but ideally true angular template code, including custom components like
<ui-button icon="up.svg" (click)='...'></ui-button>
<ui-button icon="down.svg" (click)='...'></ui-button>
...leading in the outer component's top bar to:
<section class='some-flexbox'>
<ui-button icon="home.svg" (click)='...'></ui-button>
<ui-button icon="up.svg" (click)='...'></ui-button>
<ui-button icon="down.svg" (click)='...'></ui-button>
<ui-button icon="help.svg" (click)='...'></ui-button>
<ui-button icon="account.svg" (click)='...'></ui-button>
</section>
Thinking about it, the click events of those buttons added should find their way back home into the child, sigh...
update
ngTemplateOutlet sounds pretty interesting
We can also take the template itself and instantiate it anywhere on the page, using the ngTemplateOutlet directive:
Examining, still unsure how...

There are two possible ways you can achieve the desired behavior.
Here is a quick explanation for both the solutions.
1. Using PortalModule Demo Link
You can define a template inside child component's template file.
then grab the reference of that template inside your child component file using
@viewChiddecorator.then you can create a
TemplatePortalusing that template ref and pass that portal to the parent whenever you want.And the parent component's template file may look like this.
that's it. Now you have rendered a template to the parent component and the component still has bindings for
clickevent. And the click event handler is defined inside the child component.The same way you can use ComponentPortal or DomPortal
2. Using custom directive Demo Link
You can create one angular directive as follows which will move the elements from its host component to the parent of the host component.
And then you can use this directive on any component.
here
<app-button-group>has following template file.So our directive will move both the button element to the parent component of its host. hare we are just moving DOM nodes in the DOM tree so all the events bound with those elements will still work.
We can modify the directive to accept a class name or an id and to move only those elements which with that class name or the id.
I hope this will help. I suggest reading docs for more info on PortalModule.