Angular Interview Questions Rxjs Change Detection 2025 Interview Questions & Answers

40 questions available

Q1:

How does Angular’s new Signal-based reactivity differ from Zone.js?

Mid

Answer

Signals: Pull-based change reactivity Fine-grained updates No global dirty checks Zone.js: Monkey patches events Triggers global change detection Signals avoid unnecessary component tree checks.
Q2:

What is the new Angular hydration and how does it speed up SSR?

Mid

Answer

Angular 17+ uses non-destructive hydration: Browser reuses server-generated DOM Angular attaches event listeners without re-rendering Improves first interaction time.
Q3:

Explain the difference between deferred loading and lazy loading.

Mid

Answer

Lazy Loading: Load modules on route activation Deferred Loading (Angular 17): Automatic component loading based on: viewport visibility network conditions browser idle time
Q4:

Why is zoneless Angular faster?

Mid

Answer

No global change detection cycles No overhead from monkey-patching events Signals or manual change detection govern updates.
Q5:

How do standalone components remove the need for NgModule?

Mid

Answer

Standalone components: Declare their own imports Can be bootstrapped directly Simplify architecture Enable tree-shaking of unused dependencies.
Q6:

What happens inside Angular’s change detection algorithm?

Mid

Answer

Angular performs: Unidirectional data flow checks Runs update functions for each binding Compares previous & current values Re-renders affected DOM parts Under OnPush, only checks: Input changes Events Observable emissions
Q7:

Why is OnPush ineffective if you mutate objects?

Mid

Answer

Angular compares references, not values. Mutating objects silently ? no change detection.
Q8:

Explain the role of DestroyRef in Angular 16+.

Mid

Answer

Used to: Clean up resources on component destruction Auto-unsubscribe Replace ngOnDestroy Works well with Signals and RxJS.
Q9:

What is a View Engine orphan provider and why does it cause DI leaks?

Mid

Answer

Happens when: Providers are created outside component lifecycle No module boundary to destroy them Standalone architecture reduces such leaks.
Q10:

What is the difference between Effects (signals) vs RxJS Effects (NgRx)?

Mid

Answer

Signal Effects: Auto-track dependencies Trigger on input mutation NgRx Effects: Reactive side-effects for global state Powered by RxJS streams Complementary, not replacements.
Q11:

What is partial hydration?

Mid

Answer

Angular hydrates: Only interactive components Leaves static ones untouched Better for CMS/marketing websites.
Q12:

How does Angular’s router reuse strategy improve performance?

Mid

Answer

Router can: Cache component instances Restore state instantly Avoid re-render and re-fetch Useful for tab-based UIs.
Q13:

Why should you avoid function calls inside templates?

Mid

Answer

Functions run: On every change detection cycle Causes: Performance degradation DOM thrashing
Q14:

How do Signals solve performance issues with template expressions?

Mid

Answer

Signals store: Cached computed values Update only when dependent signals change.
Q15:

Why is async pipe better than manual subscription?

Mid

Answer

Because it: Auto-unsubscribes Integrates with change detection Avoids memory leaks Uses smart scheduling
Q16:

Why does Angular recommend inject() instead of constructors?

Mid

Answer

Benefits: Easier testing Lazy service creation Tree-shakable providers Better DI in functional components
Q17:

Explain how Angular defers scripts to reduce TTI.

Mid

Answer

Angular CLI outputs: defer for main bundle Preloads critical assets Optimizes render path
Q18:

What is the difference between providedIn: 'root' vs 'platform' vs 'any'?

Mid

Answer

root: Singleton platform: Shared across multiple Angular apps any: New instance per lazy module
Q19:

How does Angular perform template compilation (Ivy)?

Mid

Answer

Ivy converts templates to: Instruction sets (??elementStart, ??bind) Executed directly for DOM creation Highly optimized and tree-shakable
Q20:

Why are trackBy functions essential in ngFor?

Mid

Answer

Without trackBy: Angular destroys & re-creates entire DOM list With trackBy: Only changed items are re-rendered
Q21:

What is the role of hydration annotations?

Mid

Answer

They mark: Event boundaries Dynamic zones for re-hydration Pre-existing DOM elements to reuse
Q22:

Explain router fetch priorities.

Mid

Answer

Angular configures: Eager preload Network-aware preload Idle-time preload Improves routing speed.
Q23:

Why does Ivy allow removing entryComponents?

Mid

Answer

Because: Ivy compiles everything on demand Component factories auto-generated
Q24:

What is a schema error in Angular (Ivy)?

Mid

Answer

Occurs when: Template refers to unknown element/attribute Solutions: Import correct standalone component Add CUSTOM_ELEMENTS_SCHEMA
Q25:

What is a Signal Writable vs Signal Computed?

Mid

Answer

Writable: const count = signal(0); count.set(1) Computed: const total = computed(() => count() * 2);
Q26:

Why is content projection expensive?

Mid

Answer

Because: Multi-slot projections require DOM rearranging Change detection runs across projected nodes
Q27:

How does Angular handle DI for lazy-loaded routes?

Mid

Answer

Each lazy route gets: Its own injector tree Scoped service instances Isolated dependency contexts
Q28:

What is hydration mismatch?

Mid

Answer

Occurs when: Server-rendered DOM ? Client-rendered DOM Angular logs hydration errors and re-renders component.
Q29:

How do you optimize Angular apps for Largest Contentful Paint (LCP)?

Mid

Answer

Defer JS Preload above-the-fold components Image optimization Remove blocking imports
Q30:

Why is Angular faster without Zone.js?

Mid

Answer

Because: No event monkey-patching No global digests Only Signal-triggered updates Better FPS on complex UI
Q31:

Difference between cold, hot, and warm observables with real examples.

Mid

Answer

Cold: Unicast New data for every subscription Example: of(), from() Hot: Multicast Data shared Example: Subject, DOM events Warm: Hot but delayed subscription Example: shareReplay caching
Q32:

Why is switchMap considered dangerous when handling user actions?

Mid

Answer

Because: Cancels previous inner stream Useful for autocomplete But for critical actions ? may drop requests.
Q33:

Why does mergeMap cause overload in API calls?

Mid

Answer

Because it does NOT cancel prior requests. Can hammer backend.
Q34:

How does auditTime differ from throttleTime?

Mid

Answer

auditTime emits latest value after silence window. throttleTime emits first value and ignores rest.
Q35:

Why should you always return a new observable in catchError?

Mid

Answer

Otherwise stream completes permanently ? no further emissions.
Q36:

How does Subject differ from ReplaySubject?

Mid

Answer

Subject: No replay Emits new values only ReplaySubject: Stores buffer of last N values Replays to new subscribers
Q37:

Why is shareReplay({ bufferSize: 1, refCount: true }) recommended?

Mid

Answer

Prevents: Memory leaks Endless subscriptions Cold source repeated execution.
Q38:

What is the difference between concatMap and exhaustMap?

Mid

Answer

ConcatMap: Executes tasks sequentially ExhaustMap: Ignores new emissions until inner observable completes Great for "Login" button spam.
Q39:

Why does takeUntil with componentDestroy$ leak memory if not completed?

Mid

Answer

takeUntil only stops emissions if: destroy$ emits AND completes If destroy$ doesn't complete ? subscribers linger.
Q40:

How do schedulers optimize RxJS performance?

Mid

Answer

Schedulers control: Execution context Queue type Async timing Examples: asyncScheduler ? non-blocking queueScheduler ? sync batch animationFrameScheduler ? UI smooth animations