0

I want my static menu to be inside my both children components, how to achieve that?

I tried with ng-template, ng-content, ng-container, ngTemplateOutlet directives but I didn't find an example that works with router-outlet. enter image description here

I don't want to duplicate my menu in children.

Here is start with stackblitz

1 Answer 1

1

You can create a common component to be reused:

export class MenuComponent implements OnInit {}

Place the menu related css and html in the component's css and html file.

Once you done that, you can place it in your child component's html like:

Child 1

<div>
    <app-menu></app-menu>
    <p>Child 1</p>
</div>

Child 2

<div>
    <app-menu></app-menu>
    <p>Child 2</p>
</div>
1
  • Ok it was not what I was looking for, but I think there is no other way... That's what I finally doing too.
    – A. Morel
    Commented Dec 22, 2022 at 8:29

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.