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

Function setScopeOnDeclaredComponents

packages/core/src/render3/jit/module.ts:502–522  ·  view source on GitHub ↗

* Some declared components may be compiled asynchronously, and thus may not have their * ɵcmp set yet. If this is the case, then a reference to the module is written into * the `ngSelectorScope` property of the declared type.

(moduleType: Type<any>, ngModule: NgModule)

Source from the content-addressed store, hash-verified

500 * the `ngSelectorScope` property of the declared type.
501 */
502function setScopeOnDeclaredComponents(moduleType: Type<any>, ngModule: NgModule) {
503 const declarations: Type<any>[] = flatten(ngModule.declarations || EMPTY_ARRAY);
504
505 const transitiveScopes = transitiveScopesFor(moduleType);
506
507 declarations.forEach((declaration) => {
508 declaration = resolveForwardRef(declaration);
509 if (declaration.hasOwnProperty(NG_COMP_DEF)) {
510 // A `ɵcmp` field exists - go ahead and patch the component directly.
511 const component = declaration as Type<any> & {ɵcmp: ComponentDef<any>};
512 const componentDef = getComponentDef(component)!;
513 patchComponentDefWithScope(componentDef, transitiveScopes);
514 } else if (
515 !declaration.hasOwnProperty(NG_DIR_DEF) &&
516 !declaration.hasOwnProperty(NG_PIPE_DEF)
517 ) {
518 // Set `ngSelectorScope` for future reference when the component compilation finishes.
519 (declaration as Type<any> & {ngSelectorScope?: any}).ngSelectorScope = moduleType;
520 }
521 });
522}
523
524/**
525 * Patch the definition of a component with directives and pipes from the compilation scope of

Calls 6

flattenFunction · 0.90
resolveForwardRefFunction · 0.90
getComponentDefFunction · 0.90
transitiveScopesForFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…