routerLink
요소를 선택할 때 DOM의 두 개의 개별 영역에서 구성 요소를 교환하고 싶습니다. routerLink
을 2 <router-outlet>
으로 라우팅하고 각 <router-outlet>
에 대해 고유 한 구성 요소를 지정하려면 어떻게해야합니까?angular2 (2.1.1)에서 하나의 routerLink를 사용하여 여러 콘센트를 트리거하는 방법
나는 이런 식으로 뭔가를 싶습니다
<div id="region1>
<a routerLink="/view1" routerLinkActive="active">View 1</a>
<a routerLink="/view2" routerLinkActive="active">View 2</a>
<!-- First area to swap -->
<router-outlet name="sidebar"></router-outlet>
<div>
<div id="region2>
<!-- Second area to swap -->
<router-outlet name="mainArea"></router-outlet>
<div>
루트
const routes: Routes = [
{ path: '', redirectTo: 'view1', pathMatch: 'full'},
{ path: 'view1', {
outlets :
[
//one path specifies 2 components directed at 2 `router-outlets`
component: View1Sidebar, outlet : 'sidebar'
component: View1mainArea, outlet : 'mainArea'
]
}
},
{ path: 'view2', {
outlets :
[
component: View2Sidebar, outlet : 'sidebar'
component: View2mainArea, outlet : 'mainArea'
]
}
},
];