You can have multiple router-outlet in same template by configuring your router and providing name to your router-outlet, you can achieve this as follows.
Advantage of below approach is thats you can avoid dirty looking URL with it. eg: /home(aux:login) etc.
Assuming on load you are bootstraping appComponent.
{
path: 'home', // you can keep it empty if you do not want /home
component: 'appComponent',
children: [
{
path: '',
component: childOneComponent,
outlet: 'child1'
},
{
path: '',
component: childTwoComponent,
outlet: 'child2'
}
]
}
Now when /home is loaded appComponent will get load with allocated template, then angular router will check the route and load the children component in specified router outlet on the basis of name.
Like above you can configure your router to have multiple router-outlet in same route.
There seems to be another (rather hacky) way to reuse the router-outlet in one template. This answer is intendend for informational purposes only and the techniques used here should probably not be used in production.
The router-outlet is wrapped by an ng-template. The template is updated by listening to events of the router. On every event the template is swapped and re-swapped with an empty placeholder. Without this "swapping" the template would not be updated.
This most definetly is not a recommended approach though, since the whole swapping of two templates seems a bit hacky.
<div class="would-be-visible-on-mobile-only">
This would be the mobile-layout with a router-outlet (inside a template):
<br>
<ng-container *ngTemplateOutlet="myTemplateRef"></ng-container>
</div>
<hr>
<div class="would-be-visible-on-desktop-only">
This would be the desktop-layout with a router-outlet (inside a template):
<br>
<ng-container *ngTemplateOutlet="myTemplateRef"></ng-container>
</div>
<ng-template #template>
<br>
This is my counter: \{\{counter}}
inside the template, the router-outlet should follow
<router-outlet>
</router-outlet>
</ng-template>
<ng-template #trigger>
template to trigger changes...
</ng-template>