1

Is it possible to define template html like so:

<ipe-container>
    <ipe-artboard></ipe-artboard>    
</ipe-container>

in some way?

Both components are known and declared in the module where this takes place. What I see happening now is that only the ipe-container is instantiated (available in the DOM) but the ipe-artboard is nowhere to be seen. When putting this ip-artboard component un-nested it renders in the browser (DOM).

1
  • 1
    read transclusion, it will be helpful. Commented Feb 9, 2018 at 17:50

1 Answer 1

3

Yes, it is possible.

In <ipe-container>, add <ng-content> in the component template. Here is an example:

<div>Some Content</div>
<ng-content></ng-content>

Now, anything added inside the <ipe-container> selector will be rendered inside the <ng-content>.

Read more about Content Projection.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanx, works like a charm! Is this a good practice? This container is just some simple container that's placed in CSS grid layout and might be used multiple times to display different content. I want to direct the CSS layout properties from the parent component's SASS. It felt quitte natural to me to do it like this but couldn't get it to work.
Its not a bad practice at all. I am also using the same approach in a project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.