【问题标题】:Angular 6 Aux RoutingAngular 6 辅助路由
【发布时间】:2019-02-19 12:27:53
【问题描述】:

所以我的想法是我正在导航到一个管理页面,然后想在该页面中使用仅在该页面上的侧导航加载该页面中的各种组件。

所以我很确定辅助路由是最好的情况,如果我错了,请告诉我。

  { path: 'userAccounts', component: UserManagementComponent, canActivate: [LoggedInGuard]},
  { path: 'admin', component: AccountCreationPageComponent, outlet:'admin' },

<div class="navigation_items" *ngFor="let x of data" 
 [routerLink]="[ { outlets: { 'admin':['admin']}}]">{{x.id}}</div>
    <router-outlet name="admin"></router-outlet>

基本上我假设我的语法在某处有错误,或者我还不太了解 Aux 路由的工作原理,因为这不会显示管理路径

任何帮助将不胜感激。

【问题讨论】:

  • 很好地解释了 Angular 路由 here

标签: javascript angular typescript angular2-routing angular6


【解决方案1】:

看来子路由必须嵌套在父路由中,所以

  {
    path: 'userAccounts', component: UserManagementComponent, canActivate: [LoggedInGuard], children: [
      { path: 'admin', component: AccountCreationPageComponent, outlet: 'admin' }
    ]
  }

成功了。

【讨论】:

  • 你也可以选择所谓的“命名路线”
猜你喜欢
  • 1970-01-01
  • 2019-05-17
  • 2023-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多