简体   繁体   中英

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

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

<router-outlet name="start-outlet"></router-outlet>

And in Groups.component i want to redirect user to groups/permission like said in groups routing.

<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

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. Any ideas of my mistakes?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM