I decided it myself. Made some small structural changes. The route from Component1 to Component2 is performed by one <router-outlet> . Component 2 - Component3 and Component4 are executed by several <router-outlet name= "xxxxx"> . Received Content:
Component1.html
<nav> <a routerLink="/two" class="dash-item">Go to 2</a> </nav> <router-outlet></router-outlet>
Component2.html
<a [routerLink]="['/two', {outlets: {'nameThree': ['three']}}]">In Two...Go to 3 ... </a> <a [routerLink]="['/two', {outlets: {'nameFour': ['four']}}]"> In Two...Go to 4 ...</a> <router-outlet name="nameThree"></router-outlet> <router-outlet name="nameFour"></router-outlet>
'/two' represents the parent component, and ['three'] and ['four'] represents the link to the corresponding children of component2, Component3.html and Component4.html are the same as in the question.
router.module.ts
const routes: Routes = [ { path: '', redirectTo: 'one', pathMatch: 'full' }, { path: 'two', component: ClassTwo, children: [ { path: 'three', component: ClassThree, outlet: 'nameThree' }, { path: 'four', component: ClassFour, outlet: 'nameFour' } ] },];
saugandh k
source share