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

Function detachView

packages/core/src/render3/view/container.ts:149–179  ·  view source on GitHub ↗
(lContainer: LContainer, removeIndex: number)

Source from the content-addressed store, hash-verified

147 * @returns Detached LView instance.
148 */
149export function detachView(lContainer: LContainer, removeIndex: number): LView | undefined {
150 if (lContainer.length <= CONTAINER_HEADER_OFFSET) return;
151
152 const indexInContainer = CONTAINER_HEADER_OFFSET + removeIndex;
153 const viewToDetach = lContainer[indexInContainer];
154
155 if (viewToDetach) {
156 const declarationLContainer = viewToDetach[DECLARATION_LCONTAINER];
157 if (declarationLContainer !== null && declarationLContainer !== lContainer) {
158 detachMovedView(declarationLContainer, viewToDetach);
159 }
160
161 if (removeIndex > 0) {
162 lContainer[indexInContainer - 1][NEXT] = viewToDetach[NEXT] as LView;
163 }
164 const removedLView = removeFromArray(lContainer, CONTAINER_HEADER_OFFSET + removeIndex);
165 removeViewFromDOM(viewToDetach[TVIEW], viewToDetach);
166
167 // notify query that a view has been removed
168 const lQueries = removedLView[QUERIES];
169 if (lQueries !== null) {
170 lQueries.detachView(removedLView[TVIEW]);
171 }
172
173 viewToDetach[PARENT] = null;
174 viewToDetach[NEXT] = null;
175 // Unsets the attached flag
176 viewToDetach[FLAGS] &= ~LViewFlags.Attached;
177 }
178 return viewToDetach;
179}
180
181/**
182 * Inserts a view into a container.

Callers 5

removeMethod · 0.90
detachMethod · 0.90
destroyMethod · 0.90
detachExistingViewFunction · 0.90

Calls 4

detachMovedViewFunction · 0.90
removeFromArrayFunction · 0.90
removeViewFromDOMFunction · 0.90
detachViewMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…