Angular interview questions and answers for frontend developers
Angular interview questions test how well you understand the framework's machinery: change detection and OnPush, dependency injection and its injector tree, RxJS streams, and the move from NgModules to standalone components and signals. Expect concept questions, a component or form to build, and a debugging question about a view that does not update or a subscription that leaks. Because Angular changes quickly between versions, say which version you have worked with and describe both the older and newer way where they differ.
By Evin JohnPublished 8 min read
What Angular interviews look like
Angular is common in enterprise frontend teams, banking and insurance portals, internal admin tools and consultancies, so Angular developer interviews often value structure and maintainability over clever tricks. A typical loop has a framework concept screen, a TypeScript and RxJS round, a build or code review exercise, and for senior roles a conversation about migrating a large application across versions. Plain frontend topics such as the DOM, CSS and browser performance are covered in frontend developer interview questions.
- Framework conceptsComponents, bindings, DI, change detection, modules versus standalone, lifecycle hooks.
- RxJS and asyncOperators such as switchMap, subjects, unsubscribing, and when signals replace streams.
- Build or reviewA form with validation, a list with a search box, or a component that re-renders too often.
- ArchitectureFolder and feature structure, state management, lazy loading, testing and upgrade strategy.
Angular fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What are the building blocks of an Angular app? | Overview | Components with templates, directives that change elements or structure, pipes that format values, services provided through DI, and the router. Everything is written in TypeScript and compiled ahead of time. |
| NgModule versus standalone components? | App structure | An NgModule declares components and exports them for other modules. A standalone component lists its own imports and needs no module. Recent versions treat components as standalone by default and bootstrap with bootstrapApplication. |
| Explain the four kinds of binding. | Templates | Interpolation {{ }} and property binding [prop] push data into the view, event binding (event) sends events out, and two-way binding [(ngModel)] or a model input combines both. |
| Component versus directive? | Directives | A component is a directive with a template. Attribute directives change an element's behavior or look; structural directives (and the newer built-in control flow) add or remove parts of the DOM. |
| What replaced *ngIf and *ngFor? | Control flow | Built-in blocks @if, @for and @switch, available from Angular 17. @for requires a track expression, which keeps DOM nodes stable when the list changes. |
| Pure versus impure pipes? | Pipes | A pure pipe reruns only when its input reference changes, so it is cheap. An impure pipe runs on every change detection pass. Pure pipes are also the right replacement for calling methods in templates. |
| Which lifecycle hooks do you actually use? | Lifecycle | ngOnInit for setup that needs inputs, ngOnChanges to react to input changes, ngAfterViewInit for view queries, ngOnDestroy (or DestroyRef) for cleanup. The constructor is for injection only. |
| ViewChild versus ContentChild? | Queries | ViewChild finds elements in the component's own template; ContentChild finds content projected in through ng-content. They become available at different lifecycle points. |
| How do parent and child components communicate? | Data flow | Inputs down and outputs (events) up, a shared service for siblings, and signals or a store for state many components read. |
| What does AOT compilation give you? | Build | Templates are compiled at build time, so errors show up earlier, the browser downloads no compiler and rendering starts faster. It is the default for builds. |
Change detection and signals questions
Change detection is the most common deep-dive. Traditionally Zone.js patched async APIs such as timers, events and XHR, and after each one Angular checked the component tree from the root. OnPush narrows that: a component is checked only when an input reference changes, an event fires inside it, an async pipe emits, a signal it reads changes, or you mark it for check. Signals go further by telling Angular exactly which views read a changed value, which is what makes zoneless change detection possible.
import { ChangeDetectionStrategy, Component, computed, input, signal } from "@angular/core";
type Item = { id: number; name: string; priceCents: number };
@Component({
selector: "app-cart",
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
@for (item of items(); track item.id) {
<p>{{ item.name }}</p>
} @empty {
<p>Your cart is empty.</p>
}
<p>Total in cents: {{ totalCents() }}</p>
<button (click)="discountPercent.set(10)">Apply 10% off</button>
`,
})
export class CartComponent {
items = input.required<Item[]>();
discountPercent = signal(0);
totalCents = computed(() => {
const sum = this.items().reduce((acc, item) => acc + item.priceCents, 0);
return Math.round(sum * (1 - this.discountPercent() / 100));
});
}- signal, computed and effect: what is each for? A signal holds a value and notifies readers when it changes. computed derives a read-only value and recalculates lazily when its inputs change. effect runs side effects such as logging or syncing to storage; it should not be the way you derive state.
- Why did my OnPush component not update? The parent mutated an array or object in place, so the input reference stayed the same. Create a new reference, use a signal, or call markForCheck after an update Angular cannot see.
- What is ExpressionChangedAfterItHasBeenCheckedError? A dev-mode check found a binding that changed during the same pass, often because a child changed parent state in a lifecycle hook. Move the change earlier, derive it with computed, or restructure the data flow; do not hide it with setTimeout.
- What does zoneless change detection mean? Running without Zone.js, so Angular relies on signals, the async pipe, events and explicit notifications to know when to refresh. Newer projects start this way; older apps need OnPush-friendly code before they can switch.
- Signals or RxJS? Signals for synchronous state that templates read. RxJS for streams over time: user input with debounce, websockets, retries and cancellation. toSignal and toObservable bridge the two.
RxJS and dependency injection questions
import { AsyncPipe } from "@angular/common";
import { HttpClient } from "@angular/common/http";
import { Component, Injectable, inject } from "@angular/core";
import { FormControl, ReactiveFormsModule } from "@angular/forms";
import { Observable, debounceTime, distinctUntilChanged, of, switchMap } from "rxjs";
@Injectable({ providedIn: "root" })
export class SearchService {
private http = inject(HttpClient);
search(term: string): Observable<string[]> {
return this.http.get<string[]>("/api/search", { params: { q: term } });
}
}
@Component({
selector: "app-search",
imports: [ReactiveFormsModule, AsyncPipe],
template: `
<input [formControl]="query" placeholder="Search" />
<ul>
@for (result of (results$ | async) ?? []; track result) {
<li>{{ result }}</li>
}
</ul>
`,
})
export class SearchComponent {
private searchService = inject(SearchService);
query = new FormControl("", { nonNullable: true });
results$ = this.query.valueChanges.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((term) => (term ? this.searchService.search(term) : of([]))),
);
}| Question | What it tests | What a strong answer shows |
|---|---|---|
| switchMap, mergeMap, concatMap or exhaustMap? | Flattening | switchMap cancels the previous inner stream (search). mergeMap runs all in parallel. concatMap queues them in order (saves). exhaustMap ignores new ones while busy (a login button). |
| Subject, BehaviorSubject and ReplaySubject? | Subjects | A Subject has no current value. BehaviorSubject holds the latest value and gives it to new subscribers. ReplaySubject replays a set number of past values. |
| How do you avoid memory leaks from subscriptions? | Cleanup | Prefer the async pipe or toSignal, which clean up for you. For manual subscriptions use takeUntilDestroyed or unsubscribe in ngOnDestroy. HTTP calls complete on their own; interval and store streams do not. |
| Cold versus hot observables? | Semantics | A cold observable starts its work per subscriber, so two subscriptions to an HTTP call make two requests. A hot one shares a running source. shareReplay turns one into the other, with care about when it completes. |
| What does providedIn: 'root' mean? | DI | One instance for the whole app, created on first use and tree-shaken away if nothing injects it. |
| Provider on a component versus in root? | Injector tree | A provider on a component gives each instance of that component, and its children, their own service instance. Useful for per-widget state, surprising when you expected a singleton. |
| inject() versus constructor injection? | DI style | Both resolve from the same injector. inject() works in field initializers and functions such as guards and interceptors, but only inside an injection context. |
| What is an InjectionToken for? | DI | Injecting things that are not classes, such as a config object or an API base URL, with a typed token. |
Routing and forms questions
import { inject } from "@angular/core";
import { CanActivateFn, Router, Routes } from "@angular/router";
import { AuthService } from "./auth.service";
export const authGuard: CanActivateFn = () => {
const auth = inject(AuthService);
return auth.isSignedIn() ? true : inject(Router).createUrlTree(["/login"]);
};
export const routes: Routes = [
{ path: "", loadComponent: () => import("./home.component").then((m) => m.HomeComponent) },
{
path: "admin",
canActivate: [authGuard],
loadChildren: () => import("./admin/admin.routes").then((m) => m.ADMIN_ROUTES),
},
];- How does lazy loading work? loadComponent or loadChildren returns a dynamic import, so the build splits that code into its own chunk, fetched on first navigation. Preloading strategies can fetch it in the background after the first page loads.
- Guard, resolver or both? A guard decides whether navigation may happen. A resolver fetches data before the route activates, which delays the page; many teams load inside the component with a loading state instead.
- Why return a UrlTree from a guard instead of calling navigate? It cancels the current navigation and redirects in one step, without racing two navigations.
- Reactive or template-driven forms? Reactive forms are built in TypeScript, typed, easy to test and suited to complex validation. Template-driven forms are quicker for small forms and rely on ngModel.
- How do you write a cross-field validator? A validator function on the FormGroup that reads both controls, such as password and confirmation, and returns an error object or null.
- What is ControlValueAccessor? The interface that lets a custom component behave like a form control, so formControlName works on your date picker the same way it works on an input.
- How do you read route parameters? ActivatedRoute's paramMap observable, or bind them straight to component inputs with the router's component input binding option.
Senior Angular and performance questions
| Scenario | Likely cause | What to say you would check |
|---|---|---|
| Typing in one input makes the whole page lag. | Too much change detection | Profile with Angular DevTools. Move heavy components to OnPush or signals, replace method calls in templates with pure pipes or computed, and debounce the input. |
| A long list re-creates every row on refresh. | Tracking | The track expression uses the object rather than a stable id, so new objects from the API look like new rows. Track by id; virtualize very long lists. |
| The initial bundle is far over budget. | Eager imports | Check the build stats, lazy load feature routes, use @defer for heavy below-the-fold widgets, and look for a big library imported into a shared module. |
| The same HTTP call fires three times. | Cold observable | Three async pipes or subscriptions on one cold stream. Subscribe once, use shareReplay carefully, or convert to a signal. |
| Memory climbs every time a user opens a dialog. | Leaked subscriptions | Subscriptions without cleanup, or listeners on window. Use takeUntilDestroyed or DestroyRef and check heap snapshots. |
| A planned upgrade spans several major versions. | Migration | Upgrade one major at a time with the official update guide and ng update, fix deprecations at each step, run tests, and adopt standalone and signals gradually. |
- How does server-side rendering work in Angular? The app renders on the server for the first response, and hydration reuses that DOM in the browser instead of destroying and rebuilding it. Code that touches window or document must be guarded or run after render.
- What does @defer do? Splits part of a template into a lazily loaded chunk, triggered on idle, on viewport, on interaction or by a condition, with placeholder and loading blocks.
- How do you manage state in a large app? Services with signals for most feature state; a store library such as NgRx when many features share complex state and you want strict, traceable updates. Say why, not just which.
- How do HTTP interceptors work? Functions registered with the HTTP client that see every request and response: add auth headers, retry, map errors, show a global spinner.
Fictional example
- Interviewer
- A product card uses OnPush. The parent adds a discount to the product, but the card still shows the old price. What is going on?
- Candidate
- My first suspect is mutation. If the parent does product.price = newPrice, the input still points at the same object, so OnPush sees no change and skips the card. I would fix it at the source: have the parent create a new product object, or better, hold products in a signal and update it immutably so every reader is notified. markForCheck would also work but treats the symptom. While I am there I would check that the card does not copy the input into a local field in ngOnInit, because that copy would go stale even with a new reference. With signal inputs I would derive the price with computed instead.
Angular practice plan
- Day 1: build a standalone component tree with inputs, outputs and @for with track, then switch every component to OnPush and fix what breaks.
- Day 2: rebuild the same state with signals and computed; explain out loud when effect is and is not appropriate.
- Day 3: write the search box with switchMap, then swap in mergeMap and watch the stale-result bug appear.
- Day 4: add lazy routes, a functional guard and a typed reactive form with a cross-field validator.
- Day 5: profile a slow page with Angular DevTools and do a timed mock of the concept round.
If you are comparing frameworks for the same role, read Next.js interview questions. For the wider loop, software engineer interview questions covers coding rounds and behavioral interview questions covers the stories most Angular teams still ask for.
The hard part of change detection questions is explaining a chain of cause and effect cleanly. Natively, an AI interview assistant for Mac and Windows, writes a transcript of your mock Angular interview on your computer so you can hear where the explanation jumped a step. In practice it can read a template or a console error from a screenshot and suggest a fix, and on Pro or the free trial it can use the résumé and job description you add. The transcript and notes are there afterward to review.
Questions people ask
What Angular questions are asked in interviews?
Components and bindings, standalone components versus NgModules, lifecycle hooks, change detection and OnPush, signals, RxJS operators such as switchMap, dependency injection, lazy routing with guards, reactive forms and performance.
What is the difference between signals and RxJS in Angular?
Signals hold synchronous state that templates read and update precisely. RxJS handles streams over time such as debounced input, websockets and cancellable requests. toSignal and toObservable connect the two.
Why doesn't my OnPush component update?
Usually because an input object or array was mutated in place, so its reference did not change. Pass a new reference, use signals, or mark the view for check.
Are NgModules still asked about in Angular interviews?
Yes, because many production apps still use them. Be ready to explain both NgModules and standalone components and how you would migrate between them.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
