MCPcopy Create free account
hub / github.com/angular/angular / provideRouter

Function provideRouter

packages/router/src/provide_router.ts:110–124  ·  view source on GitHub ↗
(routes: Routes, ...features: RouterFeatures[])

Source from the content-addressed store, hash-verified

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

Calls 2

makeEnvironmentProvidersFunction · 0.90
mapMethod · 0.80

Tested by 10

configureTestingModuleFunction · 0.72
setupFunction · 0.72
setupRouterFunction · 0.72
setupFunction · 0.72
guardsIntegrationSuiteFunction · 0.72