【发布时间】:2021-11-19 20:43:20
【问题描述】:
我会导航到我的应用程序中的一个子组件。
this.router.navigateByUrl(this.rightsService.pathToRedirectTo).then((data) => {
console.log(data)
});
当我通过 /mainRoute 时它正在工作
路由:
{ path: 'mainRoute', loadChildren: () => import('./xxx/xxxx').then(m => m.xxxModule) },
但当我通过 /mainRoute/subRoute/1 时不重定向 ( data = false )
我的路由如下:
{ path: 'subRoute/:id', canActivate: [ViewGuard], component: ViewComponent },
我不知道为什么第二种情况不起作用?
这是我的父路由
{ path: 'login', component: LoginComponent },
{ path: 'mainRoute', loadChildren: () => import('./main/main.module').then(m => m.mainModule) },
{ path: '**', redirectTo: 'login' }];
然后在mainModule里面
我有路由:
{ path: 'subRoute/:id', canActivate: [ViewGuard], component: ViewComponent },
{ path: 'subroute/:id/childRoute/:sId', canActivate: [SViewGuard], component: SiewComponent }];
【问题讨论】:
标签: javascript angular typescript angular-routing