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)

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.

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.

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.

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.

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().

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.

Topic: Components & templates (Order 1)

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.

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.

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.

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]).