[英]Angular Routing child routes
I have pretty weird question about routing.我对路由有一个很奇怪的问题。 That's my code so far:
到目前为止,这是我的代码:
app.component.html
<router-outlet></router-outlet>
Main routing module主路由模块
const routes: Routes = [
{ path: "", component: LogOnComponent },
{ path: "groups", loadChildren: () => import ('./groups/groups.module').then(m => m.GroupsModule), canActivate: [AuthGuard]},
];
Child routing in Groups.module Groups.module 中的子路由
const routes: Routes = [
{ path: '', component: MenuComponent, children: [
{ path: '', component: GroupsComponent, outlet: 'start-outlet' },
{ path: 'permissions', component: PermissionsComponent, outlet: 'start-outlet' }
]
},
];
And Menu.component has a line with child routing并且 Menu.component 与子路由有一行
<router-outlet name="start-outlet"></router-outlet>
And in Groups.component i want to redirect user to groups/permission like said in groups routing.在 Groups.component 我想将用户重定向到组/权限,就像组路由中所说的那样。
<a [routerLink]="['permissions']" [state]="{ groupId: content.data.groupId }">link</a>
The problem is redirection doesn't work.问题是重定向不起作用。 Angular said that he can't find this route
Angular 说找不到这条路线
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'groups/permissions' Error: Cannot match any routes. URL Segment: 'groups/permissions'
What am I doing wrong?我究竟做错了什么? Tried different placement of
permissions
but none seems to work.尝试了不同的
permissions
放置,但似乎没有一个工作。 Any ideas of my mistakes?对我的错误有任何想法吗?
I created a StackBlitz code sample.我创建了一个 StackBlitz 代码示例。 Here it is: https://stackblitz.com/edit/angular-ivy-fxcqoy?file=src/app/menu/menu/menu.component.html
这里是: https://stackblitz.com/edit/angular-ivy-fxcqoy?file=src/app/menu/menu/menu.component.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.