MCPcopy Index your code
hub / github.com/angular/angular / forRoot

Method forRoot

packages/router/src/router_module.ts:127–164  ·  view source on GitHub ↗

* Creates and configures a module with all the router providers and directives. * Optionally sets up an application listener to perform an initial navigation. * * When registering the NgModule at the root, import as follows: * * ```ts * @NgModule({ * imports: [RouterModule.for

(routes: Routes, config?: ExtraOptions)

Source from the content-addressed store, hash-verified

125 *
126 */
127 static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<RouterModule> {
128 return {
129 ngModule: RouterModule,
130 providers: [
131 ROUTER_PROVIDERS,
132 typeof ngDevMode === 'undefined' || ngDevMode
133 ? config?.enableTracing
134 ? withDebugTracing().ɵproviders
135 : []
136 : [],
137 {provide: ROUTES, multi: true, useValue: routes},
138 typeof ngDevMode === 'undefined' || ngDevMode
139 ? {
140 provide: ROUTER_FORROOT_GUARD,
141 useFactory: provideForRootGuard,
142 }
143 : [],
144 config?.errorHandler
145 ? {
146 provide: NAVIGATION_ERROR_HANDLER,
147 useValue: config.errorHandler,
148 }
149 : [],
150 {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},
151 config?.useHash ? provideHashLocationStrategy() : providePathLocationStrategy(),
152 provideRouterScroller(),
153 config?.preloadingStrategy ? withPreloading(config.preloadingStrategy).ɵproviders : [],
154 config?.initialNavigation ? provideInitialNavigation(config) : [],
155 config?.bindToComponentInputs
156 ? withComponentInputBinding(
157 typeof config.bindToComponentInputs === 'object' ? config.bindToComponentInputs : {},
158 ).ɵproviders
159 : [],
160 config?.enableViewTransitions ? withViewTransitions().ɵproviders : [],
161 provideRouterInitializer(),
162 ],
163 };
164 }
165
166 /**
167 * Creates a module with all the router directives and a provider registering routes,

Callers 15

standalone.spec.tsFile · 0.45
router.spec.tsFile · 0.45
MyModuleClass · 0.45
TestModuleClass · 0.45
TestModuleClass · 0.45

Calls 9

withDebugTracingFunction · 0.90
withPreloadingFunction · 0.90
withViewTransitionsFunction · 0.90
provideRouterScrollerFunction · 0.85
provideInitialNavigationFunction · 0.85
provideRouterInitializerFunction · 0.85

Tested by 1