What is the difference between a component and a directive?
A component owns a template and its own view. A directive adds behaviour or structure to an existing element, either changing it in place or controlling whether and how often it renders.
Angular interview questions with short, practical answers. They cover the building blocks, the reactive patterns teams rely on, and the production problems senior candidates are asked to work through out loud.
Think you're ready? Take a free assessment20 questions • Free to start • No credit card
A component owns a template and its own view. A directive adds behaviour or structure to an existing element, either changing it in place or controlling whether and how often it renders.
Providers register how to create a dependency, and the injector supplies it where it is requested. Scope matters: root providers are shared application-wide, component-level providers create a new instance per component.
ngOnInit sets up after inputs are first available, ngOnChanges reacts to input changes, ngAfterViewInit runs once the view exists, and ngOnDestroy must release subscriptions, timers and listeners.
A pure pipe recomputes only when its input changes, so it is cheaper and clearer than a method call that runs on every change-detection pass.
Angular checks component bindings from the top down after events. OnPush limits checks to changed input references, template events, signals it reads and explicit markForCheck, which cuts a lot of unnecessary work.
Frequent async work such as scroll, timers or many streams triggers repeated passes over large trees. Fix it with OnPush, running noisy work outside the zone, trackBy on lists, and moving heavy computation out of templates.
Prefer the async pipe so the template manages the subscription. Otherwise unsubscribe in ngOnDestroy, or use takeUntilDestroyed / takeUntil with a destroy subject.
switchMap cancels the previous inner request, which is right for typeahead and navigation. mergeMap runs in parallel, concatMap preserves order, and exhaustMap ignores new work until the current one finishes — useful against double submits.
Reactive forms suit dynamic structures, cross-field validation and testability because the model lives in code. Template-driven forms are fine for small, mostly static inputs.
Measure the bundle and field metrics, lazy-load routes, remove heavy or duplicated dependencies, defer non-critical work, and consider server-side rendering or hydration. Verify with real user timings, not local builds.
Check provider scope and lifetime. Reset or recreate state on sign-out and route exit, avoid mutable module-level caches, and keep user-scoped data in a store whose lifecycle you control explicitly.
Attach the token in an interceptor, refresh once and share that refresh across queued requests, retry them after success, and sign the user out cleanly on failure instead of looping.
Feature areas with clear public boundaries, standalone components, shared UI and data-access layers, lazy routes, and enforced import rules so features cannot reach into each other's internals.
Tie each operator to a concrete problem such as cancellation, ordering or double submission.
Missing unsubscribes are a routine cause of leaks and duplicate network calls.
Show the measurement and the specific work causing extra change-detection passes.
Folder names are not architecture; explain ownership, dependencies and how change stays contained.
Pick Angular in InterviewGround for a 20-question assessment across components, change detection, RxJS, dependency injection, forms and architecture. Choice questions score instantly, written answers receive concise feedback, and results group your gaps into topics to review.
Your report shows a readiness score, demonstrated seniority for that assessment, strongest and weakest topics and recommended resources. It is a practice signal—not a hiring decision.
Think you're ready? Take a free assessmentThe language behaviour underneath every Angular answer.
Architecture, data flow, performance and reliability.
Compare rendering and state models across frameworks.
A structured plan for senior design interviews.