【发布时间】:2020-06-03 08:20:46
【问题描述】:
我有应用程序组件,我在其中延迟加载带有组件 profilecomponent 的 create-new-module。现在在配置文件组件中,我点击 router.navigate 并尝试加载另一个子项详细信息来代替配置文件,但它不起作用,控制台中也没有错误。
请帮忙
// App component route
const routes: Routes = [
{
path: 'create-new-emp',
loadChildren: () => import('./create-new-emp/create-new-emp.module').then(c => c.CreateNewEmpModule),
},
{ path: '', redirectTo: 'create-new-emp', pathMatch: 'full'},
{ path: '**', redirectTo: 'create-new-emp'}
];
// Emp Module Route
const routes: Routes = [
{ path: '', component: ContainerComponent,
children: [
{ path: '', component: ProfileComponent, outlet: 'form'},
{ path: 'profile', component: ProfileComponent, outlet: 'form'},
{ path: 'detail', component: DetailComponent, outlet: 'form' }] }
];
// Trying to hit below link but not working
this.router.navigate(['detail'])
<app-component>
<router-outlet>
<container-component>
<profile-component></profile-component>
</container-component>
</router-outlet>
</app-component>
【问题讨论】:
-
我建议您在 stackblitz.com 上创建一个项目来重新创建您的场景,这样我们可以在这里为您提供更好的帮助。
标签: javascript angular