MCPcopy
hub / github.com/angular/angular / provideRouter

Function provideRouter

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

Source from the content-addressed store, hash-verified

104 * @returns A set of providers to setup a Router.
105 */
106export 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
122export function rootRoute(): ActivatedRoute {
123 return inject(Router).routerState.root;

Calls 2

makeEnvironmentProvidersFunction · 0.90
mapMethod · 0.80

Tested by 12

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…