You can achieve this by specifying the router exit as follows.
Assuming you download appComponent first,
app.component.html
<header></header> <router-outlet name='content1_r1_r2'><router-outlet/> <router-outlet name='content1_r3_r4'><router-outlet/> <router-outlet name='content2'><router-outlet/> <footer></footer>
configure the router as follows:
{ path: 'r1', component: 'appComponent', children: [ { path: '', component: contentr12Component, outlet: 'content1_r1_r2' }, { path: '', component: contentr1Component, outlet: 'content2' } ] } // write same for r2 just change content1Component you want to load on /r2 route. { path: 'r3', component: 'appComponent', children: [ { path: '', component: contentr34Component, outlet: 'content1_r2_r4' }, { path: '', component: contentr3Component, outlet: 'content2' } ] } // write same for r4 just change content3Component you want to load on /r4 route.
In the above code, contentr12Component will remain the same for routes r1 and r2, contentr34Component will remain the same for r3 and r4. You can replace the names according to your component.
It also avoids the ugly url.
source share