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

Function getInherited

packages/router/src/router_state.ts:266–312  ·  view source on GitHub ↗
(
  route: ActivatedRouteSnapshot,
  parent: ActivatedRouteSnapshot | null,
  paramsInheritanceStrategy: ParamsInheritanceStrategy,
)

Source from the content-addressed store, hash-verified

264 * route is component-less.
265 */
266export function getInherited(
267 route: ActivatedRouteSnapshot,
268 parent: ActivatedRouteSnapshot | null,
269 paramsInheritanceStrategy: ParamsInheritanceStrategy,
270): Inherited {
271 let inherited: Inherited;
272 const {routeConfig} = route;
273 if (
274 parent !== null &&
275 (paramsInheritanceStrategy === 'always' ||
276 // inherit parent data if route is empty path
277 routeConfig?.path === '' ||
278 // inherit parent data if parent was componentless
279 (!parent.component && !parent.routeConfig?.loadComponent))
280 ) {
281 inherited = {
282 params: {...parent.params, ...route.params},
283 data: {...parent.data, ...route.data},
284 resolve: {
285 // Snapshots are created with data inherited from parent and guards (i.e. canActivate) can
286 // change data because it's not frozen...
287 // This first line could be deleted chose to break/disallow mutating the `data` object in
288 // guards.
289 // Note that data from parents still override this mutated data so anyone relying on this
290 // might be surprised that it doesn't work if parent data is inherited but otherwise does.
291 ...route.data,
292 // Ensure inherited resolved data overrides inherited static data
293 ...parent.data,
294 // static data from the current route overrides any inherited data
295 ...routeConfig?.data,
296 // resolved data from current route overrides everything
297 ...route._resolvedData,
298 },
299 };
300 } else {
301 inherited = {
302 params: {...route.params},
303 data: {...route.data},
304 resolve: {...route.data, ...(route._resolvedData ?? {})},
305 };
306 }
307
308 if (routeConfig && hasStaticTitle(routeConfig)) {
309 inherited.resolve[RouteTitleKey] = routeConfig.title;
310 }
311 return inherited;
312}
313
314/**
315 * @description

Callers 3

createSnapshotMethod · 0.90
resolveDataFunction · 0.90
runResolveFunction · 0.90

Calls 1

hasStaticTitleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…