(routes: Routes, ...features: RouterFeatures[])
| 104 | * @returns A set of providers to setup a Router. |
| 105 | */ |
| 106 | export function provideRouter(routes: Routes, ...features: RouterFeatures[]): EnvironmentProviders { |
| 107 | if (typeof ngDevMode === 'undefined' || ngDevMode) { |
| 108 | // Publish this util when the router is provided so that the devtools can use it. |
| 109 | ɵpublishNonCoreGlobalUtil('ɵgetLoadedRoutes', getLoadedRoutes); |
| 110 | ɵpublishNonCoreGlobalUtil('ɵgetRouterInstance', getRouterInstance); |
| 111 | ɵpublishNonCoreGlobalUtil('ɵnavigateByUrl', navigateByUrl); |
| 112 | } |
| 113 | |
| 114 | return makeEnvironmentProviders([ |
| 115 | {provide: ROUTES, multi: true, useValue: routes}, |
| 116 | {provide: ActivatedRoute, useFactory: rootRoute}, |
| 117 | {provide: APP_BOOTSTRAP_LISTENER, multi: true, useFactory: getBootstrapListener}, |
| 118 | features.map((feature) => feature.ɵproviders), |
| 119 | ]); |
| 120 | } |
| 121 | |
| 122 | export function rootRoute(): ActivatedRoute { |
| 123 | return inject(Router).routerState.root; |
searching dependent graphs…