Skip to content

Instantly share code, notes, and snippets.

@phenomnomnominal
Created March 10, 2019 10:47
Show Gist options
  • Save phenomnomnominal/4e2cad6a086b306ed5da6b8a489613bb to your computer and use it in GitHub Desktop.
Save phenomnomnominal/4e2cad6a086b306ed5da6b8a489613bb to your computer and use it in GitHub Desktop.
@NgModule({declarations: ROUTER_DIRECTIVES, exports: ROUTER_DIRECTIVES})
export class RouterModule {
// ...
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
return {
ngModule: RouterModule,
providers: [
// ...
provideRoutes(routes),
// ...
],
};
}
static forChild(routes: Routes): ModuleWithProviders {
return {ngModule: RouterModule, providers: [provideRoutes(routes)]};
}
}
export function provideRoutes(routes: Routes): any {
return [
// ...
{provide: ROUTES, multi: true, useValue: routes},
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment