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

Method destroy

packages/core/src/render3/view_ref.ts:104–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

102 }
103
104 destroy(): void {
105 if (this._appRef) {
106 this._appRef.detachView(this);
107 } else if (this._attachedToViewContainer) {
108 const parent = this._lView[PARENT];
109 if (isLContainer(parent)) {
110 const viewRefs = parent[VIEW_REFS] as ViewRef<unknown>[] | null;
111 const index = viewRefs ? viewRefs.indexOf(this) : -1;
112 if (index > -1) {
113 ngDevMode &&
114 assertEqual(
115 index,
116 parent.indexOf(this._lView) - CONTAINER_HEADER_OFFSET,
117 'An attached view should be in the same position within its container as its ViewRef in the VIEW_REFS array.',
118 );
119 detachView(parent, index);
120 removeFromArray(viewRefs!, index);
121 }
122 }
123 this._attachedToViewContainer = false;
124 }
125 destroyLView(this._lView[TVIEW], this._lView);
126 }
127
128 onDestroy(callback: Function) {
129 storeLViewOnDestroy(this._lView, callback as () => void);

Callers

nothing calls this directly

Calls 7

isLContainerFunction · 0.90
assertEqualFunction · 0.90
detachViewFunction · 0.90
removeFromArrayFunction · 0.90
destroyLViewFunction · 0.90
indexOfMethod · 0.80
detachViewMethod · 0.65

Tested by

no test coverage detected