After breaking my head a little bit (and doing some research), I was able to do something similar to what you want.
My application has a navigation bar that I want to leave it on top all the time but that it should disappear on the login screen.
My html app template looked something like this:
<app-nav-bar></app-nav-bar>
<router-outlet></router-outlet>
This would cause the bar to appear after the login screen, but if I went back to the "start screen" by some link, the bar would still be on the page. So I switched to this here:
<router-outlet name="navbar"></router-outlet>
<router-outlet></router-outlet>
With the addition of a route:
{path: 'home', component: NavBarComponent, outlet: 'navbar'}
Now, when it comes to changing routes, you can use two modes:
In routerLink (within HTML), use the following form:
[routerLink]="[{outlets: {primary: ['caminho'], navbar: ['caminho']}}]"
And in the components (Typescript), as follows:
router.navigate([{outlets: {primary: 'caminho', navbar: 'caminho'}}]);
Now, starting from the description of your problem, the primary router-outlet should be OUTSIDE wrapper (inside app.component.html) and auxiliary router-outlet inside the wrapper. You will make route changes using the helper.
Note:
The address bar will look different, something like
localhost:4200/home(navbar:home)
Where localhost:4200/home
is the route of the primary outlet and navbar:home
is the route of auxiliary outlets
The tag
<router-outlet>
is just a tag where elements should appear in the browser. Every component will appear just below that tag. I think you should do a second outlet within the wrapper and attach the route exchanges to that second.– mutlei
Even I have a problem quite similar to yours. I will implement here and then return.
– mutlei