내 라우터 구성 요소를로드하는 데 다중 라우터 - 아웃렛을 사용하고 있습니다. 외부 라우터 - 아웃렛은 login, home, 404와 같은 가장 기본적인 구성 요소를로드하는 데 사용됩니다. 중첩 된 라우터 - 콘센트를 사용하여 홈 페이지의 하위 구성 요소를로드했습니다. 해당 라우터 출력은 home.component 내부에 중첩되어 있습니다.각도 4에 중첩 된 라우터 - 아웃렛 사용
home.component.html
<app-header></app-header>
<router-outlet name="homeRoute"></router-outlet>
<app-footer></app-footer>
app.module.ts
const appRoutes: Routes = [
{path: '', component: HomeComponent, children: [
{path: '', component: DashboardComponent, outlet: 'homeRouter'},
{path: 'user', component: UserComponent, outlet: 'homeRouter'},
{path: 'user/:id', component: UserdetailComponent, outlet: 'homeRouter'}
]},
{path: 'login', component: LoginformComponent},
{path: '**', component: NotfoundComponent}
];
HomeComponent LoginformComponent 및 상기 외부 라우터 출구에서로드 할 필요가있다. 홈 구성 요소에는 홈 페이지의 하위 구성 요소를로드하는 데 사용하려는 이름이 'homeRouter'인 내부 라우터 콘센트가 포함되어 있습니다. 하지만 내부 라우터 탐색이 작동하지 않습니다. router.navigate() 메서드를 사용하고 URL을 사용하여 각 구성 요소에 액세스하려고했습니다. 그러나 두 사람 모두 예상대로 작동하지 않았습니다.
누군가이 코드의 문제점을 말해 줄 수 있습니까? 같은 문제에 대한 몇 가지 이전 질문을 조사하고 시도했지만 아무도 잘 작동하지 않았습니다. 여기
내가 (이 작품)http://localhost:4200/user
userComponent (notFoundComponent에 나던 작동합니다. 경로)http://localhost:4200/user/U001
userDetailComponent (work.still 경로를 doenst 다른 구성 요소
http://localhost:4200
dashboardComponet위한 노력의 URL입니다 ~ notFoundComponent로)
typo name = "homeRoute"outlet : 'homeRouter' – DrMabuse