
Angular Advanced Interview Questions
Angular top 25 advanced interview questions for beginners and experienced must learn
1. What is Angular change detection?
Change detection is the process Angular uses to check data changes and update the view (UI). It runs automatically when events, API calls, or async tasks happen.
2. What is ChangeDetectionStrategy?
It controls how Angular checks for changes.
Types:
- Default: checks entire component tree
- OnPush: checks only when input changes or events happen (better performance)
3. What is Angular Lifecycle Hook order?
Angular calls hooks in this order:
- ngOnChanges
- ngOnInit
- ngDoCheck
- ngAfterContentInit
- ngAfterViewInit
- ngOnDestroy
4. What is ngOnInit used for?
In Angular, the ngOnInit() runs once after component creation and is used for initial API calls and setup logic.
5. What is RxJS in Angular?
RxJS is a library for handling asynchronous data using Observables like API calls, events, streams.
6. What is an Observable?
An Observable is a data stream that emits values over time, used for async operations like HTTP requests.
7. Observable vs Promise?
- Promise: returns single value once
- Observable: can return multiple values over time and can be cancelled
8. What is Subject in RxJS?
In an RxJS library, Subject is a special Observable that can emit and receive data (both producer + consumer).
9. What is BehaviorSubject?
In an RxJS library, BehaviorSubject is a Subject that stores the latest value and gives it to new subscribers immediately.
10. What is Angular dependency injection hierarchy?
Angular creates services at different levels:
- Root level (global)
- Module level
- Component level
11. What is Ahead-of-Time (AOT) compilation?
AOT compiles Angular code before browser loads it, making app faster and more secure.
12. What is Just-in-Time (JIT) compilation?
JIT compiles Angular code in the browser during runtime (mainly used in development).
13. What is lazy loading?
In Angular, the Lazy loading loads modules only when needed instead of loading everything at start, improving performance.
14. What is tree shaking?
Tree shaking removes unused code during build time, making final bundle smaller.
15. What is Angular interceptor?
In Angular, an interceptor is used to modify HTTP requests/responses globally, like adding tokens or logging.
16. What is HttpClient in Angular?
The HttpClient is used to make API calls (GET, POST, PUT, DELETE) from Angular app.
17. What is ngZone?
In Angular, the ngZone helps Angular detect async operations and update UI automatically.
18. What is trackBy in ngFor?
In Angular, the trackBy improves performance by tracking items in a list using unique ID instead of re-rendering all items.
19. What is ViewChild?
ViewChild decorator is used to access DOM element or child component directly from parent component.
20. What is custom directive?
A custom directive is a user-created directive to change behavior or appearance of DOM elements. Command to create custom directive 'ng generate directive directive_name' or 'ng g d directive_name'.
21. What is Pure and Impure pipe?
- Pure pipe: runs only when input changes
- Impure pipe: runs on every change detection cycle
22. What is Angular module loading strategy?
- Eager loading: loads at startup
- Lazy loading: loads when needed (recommended)
23. What is SSR (Server Side Rendering)?
SSR renders Angular app on the server first and sends HTML to browser, improving SEO and initial load speed.
24. What is hydration in Angular?
Hydration is the process of making server-rendered HTML interactive on the client side.
25. What is standalone component?
Standalone components are components that do not require NgModule, introduced to simplify Angular architecture.