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

Function provideRouter

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

Source from the content-addressed store, hash-verified

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

Calls 2

makeEnvironmentProvidersFunction · 0.90
mapMethod · 0.80

Tested by 9

createNavigationHistoryFunction · 0.72
setupRouterFunction · 0.72
setupFunction · 0.72
guardsIntegrationSuiteFunction · 0.72