Use these questions to screen senior Angular developers or to prepare for an interview yourself. They cover lifecycle hooks, change detection, RxJS, dependency injection and how an Angular app is structured. Allow 45-60 minutes to work through them properly.
Lifecycle hooks
What is the difference between ngOnInit and the constructor?
The constructor initialises class members and receives injected dependencies. ngOnInit is a lifecycle hook Angular calls once the component has been initialised. Put component logic such as data fetching in ngOnInit, not in the constructor.
What is the ngOnChanges hook for?
Angular calls ngOnChanges whenever an input-bound property changes. It receives a SimpleChanges object with the previous and current value of each changed input, so you can react to the change.
What is the difference between ngAfterContentInit and ngAfterViewInit?
ngAfterContentInit runs once projected content (ng-content) has been initialised. ngAfterViewInit runs once the component's own view and its child views have been initialised.
What is ngOnDestroy used for?
Angular calls ngOnDestroy just before it destroys a component or directive. Use it to clean up: unsubscribe from observables and detach event handlers so you don't leak memory.
In what order do the lifecycle hooks run?
Constructor, then ngOnChanges, ngOnInit, ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAfterViewInit, ngAfterViewChecked and finally ngOnDestroy.
Change detection
How does Angular's change detection work?
It is unidirectional and works down the component tree. When something triggers a check, Angular walks from the root component to the leaves, compares component data and updates the DOM where it has changed.
What is ChangeDetectionStrategy.OnPush and when should you use it?
OnPush tells Angular to check a component only when an input reference changes, when an event starts in the component or one of its children, or when you trigger detection manually. It cuts out unnecessary checks, so use it where performance matters.
RxJS, dependency injection and architecture
What is the difference between a Subject and a BehaviorSubject?
A Subject holds no value and only emits to subscribers after they subscribe. A BehaviorSubject holds a current value and sends it straight away to every new subscriber, which makes it useful for storing and broadcasting state.
How does dependency injection work in Angular?
Components declare the dependencies they need and Angular resolves and injects them. Services can be provided at component or module level, and the provider configuration decides whether you get a singleton or separate instances.
What role do NgModules play?
NgModules group related components, directives, services and pipes into coherent blocks. Every app starts from a root module, and feature modules let a large app scale and load parts lazily.
Hiring rather than interviewing? See hire Angular developers or check current Angular developer salaries.
Keep reading
Same skill, other angles

