MCPcopy Create free account
hub / github.com/angular/angular / remove

Method remove

packages/core/src/linker/view_container_ref.ts:639–653  ·  view source on GitHub ↗
(index?: number)

Source from the content-addressed store, hash-verified

637 }
638
639 override remove(index?: number): void {
640 const adjustedIdx = this._adjustIndex(index, -1);
641 const detachedView = detachView(this._lContainer, adjustedIdx);
642
643 if (detachedView) {
644 // Before destroying the view, remove it from the container's array of `ViewRef`s.
645 // This ensures the view container length is updated before calling
646 // `destroyLView`, which could recursively call view container methods that
647 // rely on an accurate container length.
648 // (e.g. a method on this view container being called by a child directive's OnDestroy
649 // lifecycle hook)
650 removeFromArray(getOrCreateViewRefs(this._lContainer), adjustedIdx);
651 destroyLView(detachedView[TVIEW], detachedView);
652 }
653 }
654
655 override detach(index?: number): ViewRef | null {
656 const adjustedIdx = this._adjustIndex(index, -1);

Callers 1

clearMethod · 0.95

Calls 5

_adjustIndexMethod · 0.95
detachViewFunction · 0.90
removeFromArrayFunction · 0.90
destroyLViewFunction · 0.90
getOrCreateViewRefsFunction · 0.85

Tested by

no test coverage detected