0

当我将不推荐使用的路由器用于子路由器时,我会这样使用:

父路由器:

@Component({
  selector: 'app',
  directives: [RouterOutlet],
  template: `
    <router-outlet></router-outlet>
  `
})
@RouteConfig([
  { path: '/landing/...', name: 'Landing', component: LandingComponent }
])

子路由器:

@Component({
  selector: 'landing-component',
  directives: [RouterOutlet],
  template: `
    <router-outlet></router-outlet>      
  `
})
@RouteConfig([
  { path: '/welcome', name: 'Welcome', component: WelcomeComponent }
])
export class LandingComponent {
}

我正在尝试切换到ngrx/路由器。我怎样才能使用ngrx/router正确地做到这一点?

谢谢

4

1 回答 1

1

这就是我现在使用它的方式:

const landingRoutes: Routes = [
  { path: '/landing1', component: Landing1Component },
  { path: '/landing2', component: Landing2Component }
];

const routes: Routes = [
  { path: '/landing',
    component: LandingComponent,
    index: {
      component: WelcomeComponent
    },
    loadChildren: () => new Promise(resolve => resolve(landingRoutes))
  }
];

确保您返回promise内部loadChildren

如果您想使用异步路由进行代码拆分,请在此处查看更多详细信息。

于 2016-06-03T19:01:31.907 回答