Angular — signals, change detection & SSR
Core details
Change detection historically: zone.js monkey-patched async primitives to NgZone so Angular could schedule ApplicationRef.tick() broadly after async work completed. ChangeDetectionStrategy.OnPush limits checks to subtree input reference changes + events—and explicit markForCheck()/detectChanges() escapes when interoperating with non-Angular async.
Signals (recent mental model shift):
signal,computed,effectmodel fine-grained reactivity—the framework can narrow invalidation instead of traversing wider component trees blindly.- Interoperability:
signal/input()bindings reduce boilerplate vs manual subscription lifecycle in components.
Structure: Modules vs standalone APIs (bootstrapApplication, standalone components/pipes)—greenfield narratives favor standalone + route-level imports for tree-shakable boundaries.
SSR / SSG:
- Angular Universal (or analogous platform server) renders on server → hydration must reconcile DOM; mismatches resemble other frameworks’ hydration bugs (directive order, DOM-only APIs).
Forms & DI: Reactive forms (FormControl) vs template-driven—staff answers mention validators, immutable update patterns, and dependency injection scopes (providedIn, component providers) for clarity and testing.
Understanding
Signals are Angular’s pivot from “zone-scheduled dirty checking unless you perfected OnPush” toward “graph of reactive subscriptions orchestrated by the framework.” Interviewers probe whether you know why zone.js helped adoption (integrated ergonomics) and why it hurts (hard-to-debug long tasks, third-party patching conflicts). Combining signals with SSR pushes you toward explicit timing (afterNextRender etc.) vs DOM-before-ready mistakes.
Senior understanding
| Lens | Speak to |
|---|---|
| Performance | runOutsideAngular for hotspot polling; virtualization (@angular/cdk/scrolling), deferring rendering of heavy graphs. |
| Migration | incremental Module → standalone moves; gradual signal adoption beside RxJS (toSignal/toObservable bridges) without dual mental models exploding. |
| Testing | TestBed vs lighter constructor tests for pure services; flakiness from zone/async fake timers—be explicit about fakeAsync. |
Trap answers: “Angular is slow” without naming change detection topology or bundle budget realities; pretending signals remove all need for async coordination (AsyncPipe/scheduler edges still appear).
Diagram
See also
Last updated on
Spotted something unclear or wrong on this page?