When having a separate routing module, instead of creating an NgModule you can export router configuration directly:

export const AppRoutingModule = RouterModule.forRoot(routes, config);

or

export const FeatureRoutingModule = RouterModule.forChild(routes);

and use it in your module

@NgModule({
  imports: [
    ...
    AppRoutingModule,
    ...
  ]
})

翻译自:https://www.30secondsofcode.org/angular/s/router-module

相关链接