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

Function configureViewWithDirective

packages/core/src/render3/view/directives.ts:443–474  ·  view source on GitHub ↗

* Setup directive for instantiation. * * We need to create a `NodeInjectorFactory` which is then inserted in both the `Blueprint` as well * as `LView`. `TView` gets the `DirectiveDef`. * * @param tView `TView` * @param tNode `TNode` * @param lView `LView` * @param directiveIndex Index where

(
  tView: TView,
  tNode: TNode,
  lView: LView,
  directiveIndex: number,
  def: DirectiveDef<T>,
)

Source from the content-addressed store, hash-verified

441 * @param def `DirectiveDef`
442 */
443function configureViewWithDirective<T>(
444 tView: TView,
445 tNode: TNode,
446 lView: LView,
447 directiveIndex: number,
448 def: DirectiveDef<T>,
449): void {
450 ngDevMode &&
451 assertGreaterThanOrEqual(directiveIndex, HEADER_OFFSET, 'Must be in Expando section');
452 tView.data[directiveIndex] = def;
453 const directiveFactory =
454 def.factory || ((def as Writable<DirectiveDef<T>>).factory = getFactoryDef(def.type, true));
455 // Even though `directiveFactory` will already be using `ɵɵdirectiveInject` in its generated code,
456 // we also want to support `inject()` directly from the directive constructor context so we set
457 // `ɵɵdirectiveInject` as the inject implementation here too.
458 const nodeInjectorFactory = new NodeInjectorFactory(
459 directiveFactory,
460 isComponentDef(def),
461 ɵɵdirectiveInject,
462 ngDevMode ? def.type.name : null,
463 );
464 tView.blueprint[directiveIndex] = nodeInjectorFactory;
465 lView[directiveIndex] = nodeInjectorFactory;
466
467 registerHostBindingOpCodes(
468 tView,
469 tNode,
470 directiveIndex,
471 allocExpando(tView, lView, def.hostVars, NO_CHANGE),
472 def,
473 );
474}
475
476/**
477 * Add `hostBindings` to the `TView.hostBindingOpCodes`.

Callers 1

initializeDirectivesFunction · 0.85

Calls 5

assertGreaterThanOrEqualFunction · 0.90
getFactoryDefFunction · 0.90
isComponentDefFunction · 0.90
allocExpandoFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…