보조 경로 내부에 보조 경로가 작동하도록 설정하는 방법을 모릅니다. 내가 좋아하는 루트 구성 요소 및 경로 설정 파일이 있습니다각도 2 새 라우터 rc4 하위 보조 경로가 작동하지 않습니다.
root.routes.ts
export const rootRoute:RouterConfig=[
...ChildrenRoute,
{path:'',component:ChildrenRootComponent},
{path:'children-root',component:ChildrenRootComponent},
{path:'other',component:OtherComponent'}
];
template:
'<a routerLink='children-root'>Children root</a>
<a routerLink='other'>Other</a>
<router-outlet></router-outlet>'
및 경로와 ChildrenRootComponent이 FirstComponent 및 SecondComponent을 같은 설정 파일 :
children.routes.ts
export const ChildrenRoute:RouterConfig=[
{path:"",redirectTo:'/children-root',pathMatch:'full'},
{path:'children-root',component:ChildrenRootComponent,
children:[
{path:'',component:FirstComponent},
{path:'first',component:FirstComponent},
{path:'second',component:SecondComponent,outlet:'aux'}
]
}
];
template:
' <a routerLink='first'>First</a>
<router-outlet></router-outlet>
<a routerLink='aux:second'>Second</a>
<router-outlet name="aux"></router-outlet>'
지금 어린이 루트에서 경로
-> 두 번째이 괜찮습니다, 그러나 경로 어린이 루트 -> 처음으로가 작동하지 않음 오류 표시 :Error: Cannot match any routes: 'children-root/second'
변경 템플릿 :
' <a routerLink='first'>First</a>
<router-outlet></router-outlet>
<a routerLink='(aux:second)'>Second</a>
<router-outlet name="aux"></router-outlet>'
도 작동하지 않습니다. 오류 :.. 오류 메시지 여기 ')'
Error: Cannot match any routes: 'children-root/second)'
에주의하고,
localhost:4200/children-root/(aux:second)
다시로드 브라우저에서 다음과 같이 어떤 '(' 직접 설정 한 URL과 잘 작동 그래서 내가 설정 한 것 같아요 .. routerLink 잘못 검색, 많은, 더
A HREF가 SecondComponent에 갈 수에서 작업을 참조해야하지만, 브라우저는 라우터 콘센트에 SecondComponent를로드하지, 전체 페이지를 다시로드합니다. – PengGang
이 href는 페이지를 다시로드하지 않아야합니다. 임대에서 내 애플 리케이션에서 나는 HashLocationStrategy를 사용하고 이것과 비슷한 URL은 페이지를 새로 고침하지 않는다 : '''Second''' –
이것은 여전히 RC.5에서 문제가된다. 이것이 언제 풀릴 지 궁금하다 –