【发布时间】:2017-10-05 14:11:38
【问题描述】:
我无法直接前往子路线。我的 url 是 http://localhost:4201/home/profile 但路由器跟踪以 url: '/home' 而不是 url: '/home/profile' 开始
路由器事件:NavigationStart platform-browser.es5.js:1028 NavigationStart(id: 1, url: '/home') platform-browser.es5.js:1028 NavigationStart {id: 1, url: "/home"}
const feedsRoutes: Routes = [
{
path: '',
component: HomeComponent,
children: [
{ path: 'home', redirectTo: '', pathMatch: 'full' },
{ path: '', loadChildren: '../feeds-home/feeds-home.module#FeedsHomeModule' },
{ path: 'business', loadChildren: '../business-home/business-home.module#BusinessModule' },
{ path: 'people', loadChildren: '../people-home/people-home.module#PeopleModule' },
{ path: 'profile', loadChildren: '../profile-home/profile-home.module#ProfileModule' },
{ path: 'settings', component: SettingsComponent, data: { title: 'Settings' } }
]
}
];
这是因为将子路由加载为模块吗?
【问题讨论】:
-
您如何尝试导航到子路线?请添加代码
-
ProfileModule中定义了哪些路由?
-
profile不是home的 chikd 路线。看起来 localhost:4201/profile 是你想要的 -
如果您正在寻找嵌套路由,请使用 angular ui route 而不是 angular route。
标签: angular angular-router angular-router-loader