In Angular 2, what is right way to place the components, i can see last page as well & the next component i have loaded,?

48 Views Asked by At

Here it's my first component placed

2nd Img is html of menu component

Now suppose I make a route on a link & I call 3rd image page, I can see 1st page as well & 2nd components comes over it

1

There are 1 best solutions below

0
kedenk On

You can just place the <router-outlet></router-outlet> directive in the place you want to render your component. In this case I think your 3rd image.

If I understand you in the correct way you have to place router-outlet in a div container between your navbar and your footer to render components by clicking on a routerLink. Navbar and Footer are always visible with this approach.

Take a look at the documentation of router-outlet

Here is an example for router-outlet how it can be done.