MCPcopy Create free account
hub / github.com/angular/components / ngAfterViewInit

Method ngAfterViewInit

src/material/stepper/stepper.ts:261–288  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259 }
260
261 override ngAfterViewInit(): void {
262 super.ngAfterViewInit();
263
264 // Prior to #30314 the stepper had animation `done` events bound to each animated container.
265 // The animations module was firing them on initialization and for each subsequent animation.
266 // Since the events were bound in the template, it had the unintended side-effect of triggering
267 // change detection as well. It appears that this side-effect ended up being load-bearing,
268 // because it was ensuring that the content elements (e.g. `matStepLabel`) that are defined
269 // in sub-components actually get picked up in a timely fashion. This subscription simulates
270 // the same change detection by using `queueMicrotask` similarly to the animations module.
271 if (typeof queueMicrotask === 'function') {
272 let hasEmittedInitial = false;
273 this._animatedContainers.changes
274 .pipe(startWith(null), takeUntil(this._destroyed))
275 .subscribe(() =>
276 queueMicrotask(() => {
277 // Simulate the initial `animationDone` event
278 // that gets emitted by the animations module.
279 if (!hasEmittedInitial) {
280 hasEmittedInitial = true;
281 this.animationDone.emit();
282 }
283
284 this._stateChanged();
285 }),
286 );
287 }
288 }
289
290 override ngOnDestroy(): void {
291 super.ngOnDestroy();

Callers

nothing calls this directly

Calls 1

_stateChangedMethod · 0.80

Tested by

no test coverage detected