Bite-sized, standalone interview questions and answers for Angular. Read 5-10 per sitting. Each answer is 2-4 sentences max and stands on its own.
92 questions shown. Filter by keyword or difficulty below.
Topic: Angular bootstrap & the Ivy compiler (Order 0)
Q: What does bootstrapApplication() actually build before mounting the root component? [Beginner] ▸
It builds a root EnvironmentInjector directly from the providers array via EnvironmentNgModuleRefAdapter — no NgModule is ever instantiated. The injector is handed to bootstrap(), which runs inside NgZone.run(), waits for ApplicationInitStatus to resolve app initializers, then calls ApplicationRef.bootstrap(RootComponent). The whole injector tree exists before a single Ivy instruction runs.
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Q: How does Ivy compile a component's template differently from a virtual-DOM framework? [Intermediate] ▸
Ivy compiles each template into a plain JavaScript function containing ɵɵelementStart/ɵɵproperty/ɵɵadvance instruction calls that read and write real DOM nodes directly via an LView array. There is no virtual DOM built or diffed — the same compiled function runs on every change-detection pass, with rf & 1 (creation) instructions running once and rf & 2 (update) instructions running every tick.
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Q: What happens if bootstrapApplication() rejects — where does the error surface? [Intermediate] ▸
internalCreateApplication wraps the bootstrap in a try/catch that converts synchronous errors into a rejected Promise. If no .catch() is attached to the bootstrapApplication() call, the rejection is silent — there is no console output or global error handler that catches it. The .catch() on the returned Promise is the only surface for bootstrap failures.
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Q: What is the role of `decls` and `vars` on a ComponentDef? [Beginner] ▸
decls counts nodes, local refs, and pipes to size the creation section of the LView array. vars counts bindings to size the update-pass section. Both are plain integers passed to ɵɵdefineComponent at build time — they pre-allocate the LView slots before the template function ever runs, not describe the component for tooling.
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Q: Why does the same template function execute twice per change-detection pass? [Expert] ▸
The compiled Template(rf, ctx) function has two branches gated on the rf bitmask — rf & 1 runs creation instructions exactly once per LView, rf & 2 runs update instructions every subsequent tick. Both branches live in the same function body; the first call populates LView slots, every later call re-evaluates bindings through ɵɵadvance() + ɵɵproperty().
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Q: What's the common mistake when assuming how Angular's first render differs from later updates? [Expert] ▸
Developers assume the first render uses a special “mount” code path. In reality, ApplicationRef._loadComponent() calls this.tick(), which runs the exact same tick() → synchronize() → synchronizeOnce() loop as every subsequent update — creation instructions gate on rf & 1, update instructions on rf & 2, within the same template function. There is no separate mount path.
[Full post →](/dev-blog/angular/angular-bootstrap-sequence-ivy-render-functions/)
Topic: Components & templates (Order 1)
Q: What does `standalone: true` actually change in a component compared to the old default? [Beginner] ▸
Nothing — standalone is the compiler’s default. An @Component with no standalone field is already standalone. The old default required standalone: false plus NgModule declaration/export/import. The standalone: true flag is redundant in current Angular; removing it entirely from a codebase is the correct normalization.
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
Q: How does the `host` object's key syntax dispatch to different binding types? [Intermediate] ▸
The compiler reads the key’s punctuation, not a separate type field: a bare key 'class' is a static DOM attribute, [key] is a property binding re-evaluated on every change-detection pass, (key) is an event binding, and [attr.key] or [class.foo] scopes a property binding to one specific attribute or class. This is resolved entirely at compile time from the string syntax.
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
Q: When would you explicitly use `standalone: false` in current Angular? [Intermediate] ▸
When a component must live inside an NgModule for a legacy integration — for example, a third-party library that still expects module declarations, or a shared module boundary enforced by an older build system. In all other cases, standalone: false is leftover code from pre-standalone Angular.
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
Q: What's the mistake of writing `[class]` as a bare key in a host object instead of `[class.foo]`? [Expert] ▸
A bare 'class' is a static attribute set once at element creation, never re-evaluated. A property binding [class] or [class.foo] is re-evaluated on every change-detection tick. Using the wrong syntax means a class toggle either never updates (bare key) or updates on every pass even when unnecessary (full [class] instead of scoped [class.foo]).
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
Q: How does `[attr.disabled]` differ from `[disabled]` on a native `` host binding? [Intermediate] ▸ </h3>
[disabled] sets the DOM property, which usually works for native buttons but doesn’t give precise control over attribute presence. [attr.disabled] with a method that returns null or a string explicitly adds or removes the disabled="" attribute, which native form-control semantics and accessibility tools depend on more reliably than the property alone.
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
</div>
Q: Can a standalone component's `imports` array include `NgModule`s, or only other standalone components? [Intermediate] ▸
Both. A standalone component can import other standalone components/directives/pipes and existing NgModules — this is the intended migration path, allowing incremental adoption where new standalone components coexist with not-yet-migrated NgModule-declared libraries.
[Full post →](/dev-blog/angular/angular-components-standalone-default-host-bindings/)
## Topic: Change detection: Zone.js vs zoneless (Order 2)
{: .qa-topic }
Q: Why does Zone.js-based change detection check the entire component tree? [Expert] ▸
Zone.js monkey-patches global async APIs and fires onMicrotaskEmpty when its patched microtask queue drains. That signal carries no information about which component’s state changed — only that some async callback somewhere finished. Angular’s only correct response to “something happened, no idea what” is ViewTreeGlobal, which triggers applicationRef._tick() on the full tree.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
Q: What does the `NotificationSource` enum do in zoneless change detection? [Beginner] ▸
It tells the zoneless scheduler why notify() was called — MarkForCheck, Listener, RootEffect, DeferBlockStateUpdate, etc. Each source maps to a specific dirty flag (ViewTreeCheck, ViewTreeTraversal, RootEffects) rather than a single undifferentiated ViewTreeGlobal. This lets the scheduler skip categories of work that don’t apply, which Zone.js cannot do.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
Q: What's the practical difference between `ViewTreeGlobal` and `ViewTreeCheck`? [Beginner] ▸
ViewTreeGlobal is Zone.js’s “no information” flag — it checks everything unconditionally. ViewTreeCheck is zoneless’s “something in a view changed” flag — still broad, but it allows other flags like RootEffects to be handled independently without a full tree traversal. The precision is at the category level, not per-component.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
Q: Why does zoneless special-case `Listener` notifications when zoneless is disabled? [Expert] ▸
Under Zone.js, event listeners already run inside the Angular zone and automatically trigger onMicrotaskEmpty-driven checks. A Listener-sourced notify() in that mode would be redundant, causing double-triggered checks. The special case exists for incremental migration between the two models.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
Q: When migrating a component from Zone.js to zoneless, what's the risk if state changes happen outside signals or `markForCheck()`? [Beginner] ▸
Zoneless has no monkey-patched global fallback to catch unnotified changes. If a third-party library mutates state directly — outside signals, outside markForCheck() — the zoneless scheduler will never be notified, and the component will show stale data. Zone.js incidentally catches these mutations because it patches all async APIs.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
Q: What is `useMicrotaskScheduler` vs `scheduleCallbackWithRafRace` and why does it matter? [Expert] ▸
The zoneless scheduler chooses between scheduling a tick via microtask (runs sooner, before the next paint) or racing against requestAnimationFrame (aligns with the browser’s render timing). Microtask scheduling gives a more synchronous-feeling update; rAF-racing can reduce redundant work when multiple notifications arrive before the actual paint. The choice depends on internal scheduler state, not a fixed constant.
[Full post →](/dev-blog/angular/angular-change-detection-zonejs-vs-zoneless/)
## Topic: Signals as the reactive primitive (Order 3)
{: .qa-topic }
Q: How does a `computed()` discover its dependencies without an explicit list? [Beginner] ▸
Every signal read goes through producerAccessed, which checks whether there’s an active consumer (activeConsumer global variable — a computed() recomputing or an effect() running). If there is, the read itself records a link between that signal and the consumer. No array, no manual registration — the function body’s own execution is the dependency declaration.
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
Q: What happens when you write to a signal — does it eagerly recompute downstream computed values? [Intermediate] ▸
No. signalSetFn updates the value and calls producerNotifyConsumers, which walks the linked list of dependents and marks each one dirty = true. Nothing gets recomputed at this point. A dirty computed() only re-runs its function the next time something reads it — this is a lazy-pull model, not eager-push.
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
Q: Can a `computed()`'s dependency set change between recomputations, and is that a bug? [Intermediate] ▸
It’s by design. If a computed’s function body conditionally reads different signals on different runs, the dependency set is re-derived fresh each time via producerAccessed calls during execution. A signal that wasn’t read on the current run won’t have a link, so it won’t trigger recomputation — which is correct behavior, not a missed dependency.
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
Q: Why doesn't writing `count.set(5)` when the signal already holds `5` trigger any notifications? [Expert] ▸
signalSetFn checks node.equal(node.value, newValue) before proceeding. The default equality function (Object.is-style) returns true for identical values, so the entire notification cascade is skipped. Writing the same value is a genuine no-op, not a wasted-but-harmless notification.
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
Q: What's the tradeoff of automatic dependency tracking vs explicit dependency arrays? [Expert] ▸
Automatic tracking eliminates the “forgot to declare a dependency” bug class entirely — but any signal read during a computed’s execution, even one that was “incidental” (e.g., inside a debug console.log), becomes a real dependency. There is no way to exclude a read from tracking without an explicit escape hatch (untracked()).
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
Q: How does `consumerMarkDirty` handle a chain of `computed → computed → computed`? [Intermediate] ▸
consumerMarkDirty sets node.dirty = true and then recursively calls producerNotifyConsumers(node) — propagating dirtiness to the next downstream consumer. This means a single source signal write cascades dirty flags through the entire chain without any intermediate computed needing to eagerly recompute, which is what makes the lazy-pull model work across deep chains.
[Full post →](/dev-blog/angular/angular-signals-automatic-dependency-tracking/)
## Topic: Dependency injection: the hierarchical injector tree (Order 4)
{: .qa-topic }
Q: What are the three layers of Angular's injector hierarchy and what order does token lookup follow? [Beginner] ▸
Element injector (node injector, backed by a bloom filter) → Environment injector → Platform injector. Lookup starts at the current element’s node injector, checks embedded view injectors first if present, then walks parent node injectors upward via bloom-filter pre-checks, and only falls through to the Environment/Platform injector if nothing matches in the element chain.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: What does the 256-bit bloom filter on each node injector actually do? [Beginner] ▸
Each node injector stores 8 × 32-bit integers = 256 bits. When a directive is registered, its unique ID is hashed into one bit. During lookup, bloomHasToken tests whether that bit is set before doing a linear scan of providers — an O(1) pre-filter that avoids the expensive searchTokensOnInjector walk when the token provably isn’t on that injector.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: What's the gotcha when a component provides a token that the root also provides? [Expert] ▸
The component’s element injector silently shadows the root provider for all descendants. ChildComponent calling inject(SomeToken) resolves to the component-level override, not the root-level one, because the node injector walk finds it first. The root provider is never reached — no error, no warning, just a different instance than expected.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: What's the difference between `providers` and `viewProviders` on a component? [Beginner] ▸
providers are visible to the component itself and all its child directives. viewProviders are visible only to the component — child directives cannot see them. The includeViewProviders flag is set to true only while Angular instantiates the component itself, then flipped off so subsequent child DI lookups skip viewProviders.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: How does `@SkipSelf` change the injector lookup starting point? [Intermediate] ▸
@SkipSelf skips the current node’s injector and begins at the parent element. Without it, lookup starts locally. With it, Angular immediately walks to the parent injector, which is how you explicitly override a parent-provided token from a child — the child requests @SkipSelf so its own local provider doesn’t shadow the parent’s.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: Why does `inject()` throw if called in `ngOnInit` instead of the constructor? [Expert] ▸
inject() only works inside injection contexts — constructor, field initializer, factory function. ngOnInit is a lifecycle callback, not an injection context. The MISSING_INJECTION_CONTEXT error is thrown because the DI resolution machinery requires the component’s LView and TNode to be on the call stack, which only happens during construction.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
Q: What does the `NodeInjectorFactory.resolving` flag prevent? [Expert] ▸
Cyclic dependencies. When a factory is already being resolved (resolving === true) and is hit again during the same resolution chain, Angular throws cyclicDependencyError instead of entering an infinite loop of mutual injection.
[Full post →](/dev-blog/angular/angular-di-hierarchical-injector-tree/)
## Topic: RxJS integration & the async pipe (Order 5)
{: .qa-topic }
Q: How does the `async` pipe guarantee unsubscription without `ngOnDestroy` boilerplate? [Intermediate] ▸
Angular registers a teardown with DestroyRef.onDestroy() when async pipe first subscribes. When the component is destroyed, DestroyRef fires and calls subscription.unsubscribe(). If the Observable completes before destruction, the subscription is also released. Either path prevents a memory leak.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
Q: What happens inside `switchMap` when the source emits a new value while an inner Observable is still in-flight? [Intermediate] ▸
switchMap calls innerSubscriber.unsubscribe() on the previous inner subscription before subscribing to the new inner Observable. For HttpClient, this triggers XHR’s abort() through the RxJS teardown chain, cancelling the in-flight network request. At most one inner Observable is active at any time.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
Q: Why does `async` pipe call `markForCheck()` on every emission? [Expert] ▸
Without it, an OnPush component would never re-render — Angular would not detect the state change because OnPush only checks when inputs change, markForCheck() is called, or an event handler fires. The async pipe’s markForCheck() ensures the change detector runs on the next cycle after each emission.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
Q: What's the common mistake when manually subscribing to an Observable in a component? [Expert] ▸
Forgetting to call subscription.unsubscribe() in ngOnDestroy. The subscription keeps the component’s closure scope alive, the HTTP request keeps the connection open, and the change detector may fire into a destroyed view — producing ExpressionChangedAfterItHasBeenCheckedError. The async pipe eliminates this entire failure mode.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
Q: How does `finalize` know which teardown path triggered it — complete, error, or manual unsubscribe? [Beginner] ▸
It doesn’t need to distinguish — subscriber.add(callback) registers the callback for all three teardown paths identically. Whether the Observable completes, errors, or unsubscribe() is called explicitly (by async pipe’s DestroyRef, by switchMap’s inner cancellation, or manually), the registered finalize callback fires.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
Q: Why do signals threaten to make the `async` pipe obsolete? [Expert] ▸
Signals eliminate the need for Observable subscription management in templates entirely — a signal value is read synchronously in the template, and Angular’s reactivity system handles dependency tracking and cleanup automatically. The RxJS interop layer (toSignal, toObservable) still requires careful subscription management, but the long-term direction is signal-native data flow.
[Full post →](/dev-blog/angular/angular-rxjs-async-pipe-auto-unsubscribe/)
## Topic: Routing & lazy loading (Order 6)
{: .qa-topic }
Q: Why does `loadComponent` in Angular Router reduce initial bundle size? [Expert] ▸
Angular Router calls loadComponent via dynamic import(), which tells the bundler (esbuild/Webpack/Vite) to emit a separate JavaScript chunk per route. The chunk is fetched only when the user navigates to that route — code for features the user never visits is never downloaded.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
Q: What caching mechanism prevents `import()` from being called twice for the same lazy route? [Intermediate] ▸
RouterConfigLoader maintains a WeakMap<Route, Promise> cache per route (componentLoaders and childrenLoaders). After the first navigation loads a route’s component, subsequent visits reuse _loadedComponent / _loadedRoutes without re-fetching the network chunk. The WeakMap is keyed on the Route object, so the cache is garbage-collected if the route config is removed.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
Q: When do `canActivate` guards execute relative to the chunk being fetched? [Intermediate] ▸
Guards execute against the static route config before the chunk is fetched. If the guard denies access, the dynamic import() for that route’s component never fires — the user never downloads code they’re not authorized to see.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
Q: What's the difference between `loadChildren` and `loadComponent`? [Beginner] ▸
loadChildren loads an entire sub-route tree (an array of Routes), while loadComponent loads a single component for that specific route. Both use import() under the hood and both create separate chunks, but loadChildren also creates a new EnvironmentInjector for the child route tree.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
Q: What problem does `PreloadAllModules` solve and what's the tradeoff? [Expert] ▸
It fetches lazy chunks after the initial bundle loads while the browser is idle, so subsequent navigation is instant. The tradeoff is bandwidth — every lazy chunk is downloaded whether the user navigates there or not, trading upfront data cost for zero-latency navigation later.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
Q: Why would two lazy routes importing each other's guards cause a problem? [Expert] ▸
It creates a circular chunk graph — the bundler can’t resolve the dependency cleanly, resulting in duplicated guard code in both chunks or build errors. The fix is to refactor guards into a shared core module that both lazy routes import independently.
[Full post →](/dev-blog/angular/angular-router-lazy-loaded-bundles/)
## Topic: Forms: Reactive Forms vs Signal Forms (Order 7)
{: .qa-topic }
Q: How does AbstractControl store reactive state internally in current Angular? [Intermediate] ▸
It stores status, pristine, and touched as Angular signals (signal<FormControlStatus>, signal(true), signal(false)), then exposes them through getter properties and computed() read-only signals (_status, _pristine, _touched). The signal reads and writes are wrapped in untracked() so external consumers don’t accidentally create reactive subscriptions.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
Q: What single function is the entry point for both sync and async validation across all form APIs? [Intermediate] ▸
updateValueAndValidity(). It calls _runValidator() synchronously first, then conditionally starts _runAsyncValidator() if the status is VALID or PENDING. Whether the form is wired via formControl, formControlName, or a future signal-based directive, this is the same code path.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
Q: Why are form control signals wrapped in `untracked()` reads and writes? [Expert] ▸
Form controls are updated from multiple sources simultaneously — user input, programmatic setValue, async validators completing. Using untracked() prevents the framework from creating unintended reactive subscriptions when a parent control reads child status during updateValueAndValidity() propagation. Without it, parent-child status reads would create spurious signal dependencies.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
Q: When do `valueChanges` and `statusChanges` Observables fire relative to signal updates? [Intermediate] ▸
After the signals are updated, not before. statusReactive.set(newStatus) runs first (via the private setter wrapped in untracked()), then _events.next(StatusChangeEvent) fires, then valueChanges.emit() fires. A signal-aware template reads the latest value synchronously; a traditional template gets it on the next change detection cycle.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
Q: How does `setUpValidators()` merge validators from template directives and programmatic calls? [Intermediate] ▸
It calls mergeValidators(), which concatenates validators from two sources: model-level validators set via control.setValidators(...) and directive-level validators from template attributes (required, minlength). This function is called identically for reactive and template-driven paths — the validator layer is model-level, not directive-level.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
Q: Can you read `control.status` as a reactive dependency in a component's `computed()`? [Intermediate] ▸
Not directly. Angular wraps signal reads in untracked() to prevent accidental subscription tracking. You can read control.status imperatively (it returns the current value) or subscribe to control.statusChanges as an Observable — but using it inside a computed() will not create a reactive dependency.
[Full post →](/dev-blog/angular/angular-signal-forms-reactive-validation/)
## Topic: Content projection & control flow (Order 8)
{: .qa-topic }
Q: How does `@if` compile differently from the old `*ngIf`? [Intermediate] ▸
@if compiles into ConditionalCreate + Conditional IR operations that become conditionalCreate and conditional runtime instructions. There is no <ng-template> element, no TemplateRef, and no ViewContainerRef.createEmbeddedView() call chain. The compiler allocates a slot for the conditional block and manages the view at that slot index internally.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
Q: What does the `generateConditionalExpressions` compiler phase do for `@if/@else if/@else`? [Beginner] ▸
It flattens the chain of conditions into a single slot-index ternary expression stored in op.processed: slot = cond ? branch0Slot : (cond2 ? branch1Slot : defaultSlot). The runtime conditional() instruction evaluates this ternary to determine which embedded view slot to render — or -1 for no match.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
Q: Why doesn't `@if` create a comment node like `*ngIf` did? [Expert] ▸
@if uses slot-based embedded view infrastructure where the compiler knows the exact slot position at build time. The runtime allocates a slot for the conditional block and manages the view at that index — no placeholder comment node is needed because there’s no TemplateRef lookup or createEmbeddedView indirection.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
Q: What compiler phase converts IR ops into concrete runtime instructions like `conditionalCreate`? [Intermediate] ▸
The reify phase (reify.ts). It replaces each IR op (ConditionalCreate, RepeaterCreate, Conditional, Repeater) with a concrete instruction call (ng.conditionalCreate(), ng.repeaterCreate(), ng.conditional(), ng.repeater()), each of which manages embedded views through ViewContainerRef infrastructure.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
Q: How does `@for` handle the empty collection case? [Intermediate] ▸
The RepeaterCreate IR op carries an optional emptyView xref. When the collection is empty at runtime, the repeater instruction creates the empty embedded view instead of the main repeater view — replacing the implicit *ngFor template behavior with an explicit @empty block.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
Q: What's the performance advantage of `@if`/`@for` over `*ngIf`/`*ngFor`? [Beginner] ▸
Fewer intermediate objects (TemplateRef, ViewContainerRef.createEmbeddedView() call chain), no extra <ng-template> DOM node, and direct slot-index-based view management. The compiler produces smaller bundle size and the runtime has less change-detection overhead per conditional/repeater evaluation.
[Full post →](/dev-blog/angular/angular-control-flow-viewcontainerref-embed/)
## Topic: HttpClient & functional interceptors (Order 9)
{: .qa-topic }
Q: How does `HttpInterceptorFn` replace the class-based `HttpInterceptor` pattern? [Intermediate] ▸
It’s a plain function (req, next) => Observable<HttpEvent> registered via withInterceptors() in provideHttpClient() instead of the HTTP_INTERCEPTORS multi-provider token. The function runs inside runInInjectionContext so inject() works directly in the function body — no class, no @Injectable decorator, no constructor injection needed.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
Q: Why does `HttpInterceptorHandler` deduplicate interceptors with `new Set(...)`? [Expert] ▸
Because HTTP_INTERCEPTOR_FNS and HTTP_ROOT_INTERCEPTOR_FNS can both contain the same functional interceptor if it was registered in both an EnvironmentInjector and the root injector. Without the Set deduplication, the same interceptor would run twice per request — a real bug, not a hypothetical.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
Q: What determines the execution order of interceptors in `withInterceptors([a, b, c])`? [Intermediate] ▸
reduceRight wraps them right-to-left, producing a chain conceptually shaped as c(b(a(backend))). Execution is left-to-right: a runs first on the outgoing request and last on the incoming response. The rightmost interceptor in the array is closest to the backend.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
Q: Why is `untracked()` used when executing the interceptor chain? [Expert] ▸
HttpClient uses Angular signals internally for application stability tracking. Without untracked(), the chain execution (including the backend HTTP call) would be tracked as a dependency by any effect() or computed() active when the request was dispatched, creating an accidental reactive dependency between unrelated application state and an HTTP request.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
Q: What's the consequence of an interceptor mutating `HttpRequest` directly instead of cloning it? [Beginner] ▸
HttpRequest is immutable — mutating it directly is a bug that silently corrupts the request for every downstream interceptor. Every modification must go through req.clone({headers: ...}) to produce a new immutable request object.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
Q: How does the legacy class-based interceptor adapter work in the same pipeline as functional interceptors? [Intermediate] ▸
legacyInterceptorFnFactory injects all HTTP_INTERCEPTORS, builds a ChainedInterceptorFn linked list via adaptLegacyInterceptorToChain, and wraps the result as a single HttpInterceptorFn. The adapter reshapes the calling convention from intercept(req, handler) to the chain shape, but doesn’t need runInInjectionContext because class interceptors already resolved dependencies through constructor injection.
[Full post →](/dev-blog/angular/angular-functional-interceptors-httptinterceptorfn/)
## Topic: Server-side rendering & hydration (Order 10)
{: .qa-topic }
Q: What does non-destructive hydration do differently from destructive hydration? [Beginner] ▸
Instead of destroying the server-rendered DOM and re-creating it from scratch, Angular walks the live DOM tree, claims each node via ngh attribute annotations, and wires up event listeners, change detection, and component instances in-place. No DOM is mutated — existing nodes are claimed, not replaced.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
Q: What is the `ngh` attribute and how does `TransferState` use it? [Beginner] ▸
During SSR, Angular annotates every component host element with an ngh attribute containing a numeric index. That index is a slot into the __nghData__ array serialized inside TransferState as a <script id="ng-state"> tag. Each slot holds a SerializedView describing the component’s view structure: root node count, disconnected nodes, embedded view sizes.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
Q: What happens if a CDN strips comment nodes from the server HTML? [Intermediate] ▸
verifySsrContentsIntegrity() scans <body> for the <!--nghm--> comment marker. If it’s missing (stripped by CDN optimization), Angular throws RuntimeErrorCode.MISSING_SSR_CONTENT_INTEGRITY_MARKER and refuses to hydrate — because the ngh annotations it depends on may also have been stripped, making safe node claiming impossible.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
Q: What are the `enableLocateOrCreate*` function swaps and why are they tree-shakable? [Expert] ▸
When provideClientHydration() is called, enableHydrationRuntimeSupport() swaps the default “create” code paths (document.createElement(), document.createTextNode()) with “locate existing DOM node” implementations that walk the live DOM. If hydration is never enabled, all these functions are eliminated from the production bundle — this is the tree-shaking boundary.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
Q: How does incremental hydration interact with `@defer` blocks? [Intermediate] ▸
Incremental hydration serializes defer block metadata into __nghDeferData__ and wires jsaction attributes on host elements. Each @defer block’s hydration is deferred until its trigger fires (viewport, interaction, idle, timer) — the block’s DOM is not claimed until then, managed by the DEHYDRATED_BLOCK_REGISTRY.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
Q: Why is the `ngh` attribute removed after hydration? [Expert] ▸
It’s scaffolding — only meaningful during the hydration pass. After the DehydratedView is extracted and stored on the LView, the attribute serves no purpose and would be noise in the browser’s DOM inspector. Stripping it keeps the live DOM clean.
[Full post →](/dev-blog/angular/angular-ssr-hydration-non-destructive/)
## Topic: The Angular CLI & build pipeline (Order 11)
{: .qa-topic }
Q: How does `ng build` get from a CLI command to the actual bundler? [Intermediate] ▸
The CLI reads angular.json to resolve the builder string (e.g., @angular/build:application), maps it to the buildApplication() function, feeds it your options, and lets the builder handle everything. The builder normalizes options, sets up esbuild bundler contexts, runs the Angular AOT compiler, and orchestrates the full build pipeline — you never touch webpack or esbuild directly.
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
Q: What does `normalizeOptions()` do to your `angular.json` values? [Beginner] ▸
It transforms raw options into a fully resolved internal form: relative paths become absolute (resolved against workspace root), optimization: true expands to { scripts: true, styles: { minify: true, inlineCritical: true }, fonts: { inline: true } }, missing outputPath defaults to dist/<projectName>, and the aot flag controls AOT vs JIT mode (defaulting to true).
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
Q: Why does `executeBuild()` create separate `BundlerContext` instances for TypeScript, global styles, and component styles? [Expert] ▸
Each context can be independently invalidated and re-bundled during incremental rebuilds in watch mode. On the first build, fresh contexts are created; on rebuilds, they’re reused and only changed files are re-bundled. The SourceFileCache persists TypeScript analysis across rebuilds to avoid redundant type-checking.
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
Q: When does chunk optimization via Rollup/Rolldown actually run? [Intermediate] ▸
Only when optimizationOptions.scripts is enabled and the number of lazy chunks exceeds a configured threshold (optimizeChunksThreshold). Small projects skip the optimization pass entirely — it’s gated behind the lazy chunk count, not applied unconditionally.
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
Q: What happens when you change the underlying bundler (webpack → esbuild) — do you need to update `angular.json`? [Intermediate] ▸
No. The builder is a higher-level abstraction that encapsulates the entire build tool plus Angular-specific compilation steps. Changing the underlying tool only requires changing the builder package — angular.json’s builder field stays the same. This is the entire point of the Architect builder system.
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
Q: Why does `assertCompatibleAngularVersion()` run before anything else in the builder? [Expert] ▸
The builder is tightly coupled to the Angular compiler version. Running a builder from Angular v19 against a v17 project (or vice versa) would produce silent compilation errors or incorrect output. The version check is a hard guard against mismatched toolchain versions.
[Full post →](/dev-blog/angular/angular-cli-builders-webpack-config/)
## Topic: Testing Angular apps (Order 12)
{: .qa-topic }
Q: Why does TestBed need a PlatformRef instead of just a DOM container? [Expert] ▸
The platform provides the root injector that supplies NgZone, ApplicationRef, Compiler, and all core Angular singletons. Without a PlatformRef, the test module has no parent injector, TestBedCompiler.finalize() has nothing to parent the test module under, and every inject() call for core services fails. TestBed is a full Angular bootstrap, miniaturized for a single test.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
Q: Why does `initTestEnvironment()` throw on a second call instead of resetting? [Expert] ▸
The platform is a shared singleton that persists for the entire test session. Resetting it between tests would destroy NgZone and ApplicationRef, which are expensive to recreate and structurally identical across tests. Only the test module’s declarations and providers need per-test isolation, which resetTestingModule() handles.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
Q: What's the difference between `initTestEnvironment()` and `configureTestingModule()`? [Beginner] ▸
initTestEnvironment() is called once per suite and sets up the platform — it’s the one-time bootstrap. configureTestingModule() is called per-test and configures declarations, imports, and providers for that test’s dynamic test module. You can call configureTestingModule multiple times; initTestEnvironment only once.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
Q: How does `TestBedCompiler.finalize()` create the DI hierarchy for tests? [Intermediate] ▸
It creates an NgModuleRef with this.platform.injector as the parent injector. This makes the test module a child of the platform injector, so every ComponentFactory.create() call inside createComponent() resolves NgZone, ApplicationRef, and ChangeDetectorRef from the same injector tree a production app uses.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
Q: What's the mistake of assuming TestBed is a DOM mounting utility? [Expert] ▸
TestBed is not a DOM container — ComponentFactory.create() does the real work, not DOM manipulation. The DOM element is inserted by TestComponentRenderer, but the DI parent for the component is this.testModuleRef. The DOM insertion is incidental; the injector hierarchy is load-bearing for component instantiation to succeed.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
Q: Why does `resetTestingModule()` not destroy `NgZone` and `ApplicationRef`? [Expert] ▸
Because they’re singletons provided by the platform, not by the test module. resetTestingModule() tears down only the test module’s declarations and providers. The platform persists across tests, so NgZone and ApplicationRef are reused — this is why fixture teardown destroys components but doesn’t recreate the zone.
[Full post →](/dev-blog/angular/angular-testbed-platform-ref-component-tests/)
## Topic: State management patterns (Order 13)
{: .qa-topic }
Q: Why does `computed()` defer recomputation while `effect()` runs eagerly on creation? [Expert] ▸
Computed values derive state — they produce nothing until someone reads the result, so computing eagerly wastes cycles on values nobody reads. Effects produce side effects — their entire purpose is to do something, so deferring them would mean missing the initial trigger they were registered to observe. Both use the same reactive graph, but the scheduling hook differs.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
Q: What is the `UNSET` sentinel and why isn't `null` used instead? [Expert] ▸
UNSET is Symbol('UNSET') so that null, undefined, and 0 are all valid computed values — a computed that legitimately returns null won’t be mistaken for “never computed.” The UNSET/COMPUTING/ERRORED triple of sentinels is the state machine governing a computed’s lifecycle, each triggering different behavior in producerMustRecompute.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
Q: What is the single point of divergence between computed and effect scheduling? [Beginner] ▸
consumerMarkedDirty. ComputedNode inherits the default implementation from REACTIVE_NODE (which does nothing — just sets dirty = true). VIEW_EFFECT_NODE and ROOT_EFFECT_NODE override it to immediately schedule re-execution via the ChangeDetectionScheduler. Same graph, same dirty propagation, opposite consequences.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
Q: How does the epoch-based short-circuit in `producerUpdateValueVersion` make computed genuinely lazy? [Intermediate] ▸
If dirty is false and lastCleanEpoch === epoch, the function returns immediately without recomputing. Even if dirty is true, consumerPollProducersForChange walks the dependency list and only recomputes if a version mismatch is found. A computed that was verified clean in the current epoch can skip recomputation entirely, preventing unnecessary re-polling of producer versions in a stable graph.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
Q: Can you force a `computed()` to be eager by wrapping it in an `effect()`? [Intermediate] ▸
Yes — effect(() => { this.derived() }); reads the computed every time the effect runs, which forces the computed to recompute because reading the computed calls producerUpdateValueVersion. This is a deliberate pattern for computed values that need to always be current, though a computed with side effects is itself a design smell.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
Q: What's the risk of a deep `computed → computed → computed` chain for performance? [Beginner] ▸
consumerMarkDirty recurses through the whole chain on every source signal write. A single write can trigger many consumerMarkDirty calls for a deep chain. While no recomputation happens until read, the dirty-flag propagation itself has a cost that scales with chain depth and branching factor.
[Full post →](/dev-blog/angular/angular-signal-state-computed-lazy-effect-eager/)
## Topic: Performance: OnPush, track, and @defer (Order 14)
{: .qa-topic }
Q: How does `@defer` create chunks differently from route-level lazy loading? [Intermediate] ▸
Route-level lazy loading splits an entire component (and its template) into a separate chunk when the router navigates. @defer splits a sub-tree of an already-loaded component’s template into a separate chunk, loaded when a trigger fires within the same page. The bundling mechanism is identical (dynamic import()), but the granularity and trigger are different.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: Why doesn't `@defer` need an HTTP round-trip to discover the chunk URL? [Expert] ▸
The chunk path is statically determined at build time. The compiler’s resolveDeferDepsFns phase generates a dependencyResolverFn containing literal import('./chunk-XYZ.js') calls with paths baked in by the bundler. There is no runtime negotiation, no manifest lookup — the browser fetches a file whose path was determined during ng build.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: What compiler phase generates the `dependencyResolverFn` and how does deduplication work? [Intermediate] ▸
The resolveDeferDepsFns phase generates the resolver function. It calls getSharedFunctionReference() to ensure that if two @defer blocks in the same component share identical dependencies, they get a single shared resolver function — and the bundler produces one chunk, not two.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: How does `@defer` respect `OnPush` change detection? [Intermediate] ▸
The trigger calls triggerDeferBlock(), which notifies the scheduler via NotificationSource.DeferBlockStateUpdate — a typed notification that sets a specific dirty flag, not a Zone.js blanket notification. The parent OnPush component is only marked dirty when its own inputs or signal state change, not when the defer block transitions states.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: What happens if a `@defer` block's dynamic import fails at runtime? [Intermediate] ▸
The runtime catches the error and transitions the defer block to the Error state. If an @error block is defined, it is rendered. If not, the block stays in the Loading state with no visible content. The LDeferBlockDetails array stores cleanup functions that are invoked on error to clean up partial state.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: What is the difference between `dependencyResolverFn` in `TDeferBlockDetails` vs `LDeferBlockDetails`? [Beginner] ▸
TDeferBlockDetails is static — one per template, shared across all instances. LDeferBlockDetails is per-render instance. The resolver is stored in TDeferBlockDetails so the bundler splits it once, and every defer block using the same dependencies shares the same chunk reference.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
Q: How does `@loading (minimum 500ms)` work at the compiler/runtime level? [Intermediate] ▸
The compiler’s configureDeferInstructions phase emits a [loadingMinimumTime, loadingAfterTime] const array into the constants table. The runtime reads this config and uses ɵɵdeferEnableTimerScheduling to freeze the block in the loading state for at least the specified duration, even if the chunk loads faster. The timer scheduling is tree-shakable because the compiler only emits the reference when these parameters are present.
[Full post →](/dev-blog/angular/angular-defer-chunk-loading-performance/)
---
**Last updated:** July 2026 | **Total Q&A:** 92 across Angular
[Back to Q&A Index](/dev-blog/qa/)