* 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>, )
| 441 | * @param def `DirectiveDef` |
| 442 | */ |
| 443 | function 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`. |
no test coverage detected
searching dependent graphs…