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

Function createContainerRef

packages/core/src/linker/view_container_ref.ts:646–668  ·  view source on GitHub ↗
(
  hostTNode: TElementNode | TContainerNode | TElementContainerNode,
  hostLView: LView,
)

Source from the content-addressed store, hash-verified

644 * @returns The ViewContainerRef instance to use
645 */
646export function createContainerRef(
647 hostTNode: TElementNode | TContainerNode | TElementContainerNode,
648 hostLView: LView,
649): ViewContainerRef {
650 ngDevMode && assertTNodeType(hostTNode, TNodeType.AnyContainer | TNodeType.AnyRNode);
651
652 let lContainer: LContainer;
653 const slotValue = hostLView[hostTNode.index];
654 if (isLContainer(slotValue)) {
655 // If the host is a container, we don't need to create a new LContainer
656 lContainer = slotValue;
657 } else {
658 // An LContainer anchor can not be `null`, but we set it here temporarily
659 // and update to the actual value later in this function (see
660 // `_locateOrCreateAnchorNode`).
661 lContainer = createLContainer(slotValue, hostLView, null!, hostTNode);
662 hostLView[hostTNode.index] = lContainer;
663 addToEndOfViewTree(hostLView, lContainer);
664 }
665 _locateOrCreateAnchorNode(lContainer, hostLView, hostTNode, slotValue);
666
667 return new R3ViewContainerRef(lContainer, hostTNode, hostLView);
668}
669
670/**
671 * Creates and inserts a comment node that acts as an anchor for a view container.

Callers 3

query_spec.tsFile · 0.90
createSpecialTokenFunction · 0.90
injectViewContainerRefFunction · 0.85

Calls 4

assertTNodeTypeFunction · 0.90
isLContainerFunction · 0.90
createLContainerFunction · 0.90
addToEndOfViewTreeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…