【发布时间】:2019-05-08 03:56:59
【问题描述】:
在我的 app-routing.module 中有一个惰性模块:
const appRoutes: Routes = [
{ path: 'profile/:id',
loadChildren: './profile/profile-standalone/profile-standalone.module#ProfileStandaloneModule',
}
];
这是我的个人资料--standalone-routing.module-
const routes: Routes = [
{
path: '',
component: ProfileStandaloneComponent,
children: [
{
path: '',
redirectTo: 'outputa',
pathMatch: 'full'
},
{
path: 'outputa',
component: ProfileOutputComponent
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ProfileStandaloneRoutingModule { }
但是当我转到 url "localhost:4200/profile/123/outputa" 时,我的 "ProfileOutputComponent" 没有被调用。
知道如何让它工作吗?
【问题讨论】:
-
由于两个路由器都重定向到相同的状态,因此 Angular 将采用最先收到的第一条路由,您甚至将路径匹配“完整”,这也将满足第一个状态。尝试更改您的路线结构。
标签: javascript angular typescript routing lazy-loading