Aux маршрут внутри ребенка маршрут, не знаю, как настроить, чтобы он работал. у меня есть корневой компонент и конфигурационный файл маршрута, как:угловой 2 новый маршрутизатор rc4 ребенок aux маршрут не работает
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)'
обратить внимание здесь «)» в сообщении об ошибке, и нет «(» непосредственно установить URL следующим образом в браузере
localhost:4200/children-root/(aux:second)
перегрузочной и хорошо работать, поэтому я предполагаю, что я установил routerLink не так, искать много, не найти ничего об этом
A HREF может пойти SecondComponent, но браузер перезагружать всю страницу, а не просто загрузить SecondComponent в маршрутизатор розетке. – PengGang
Этот href не должен перезагружать страницу. При аренде в моем приложении я использую HashLocationStrategy, а URL-адрес, похожий на этот, не перезагружает страницу: '' 'Second' '' –
Это все еще проблема в RC.5. Интересно, когда это можно решить? –