PrepPilotPractise free

Angular interview questions

Components, DI, RxJS, change detection, signals

17 questions · ng · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is the difference between property binding and event binding in Angular templates?

Property binding sets a DOM property or component input using square brackets, like [value]="user.name". Event binding listens for events using parentheses, like (click)="save()". Property binding flows data from component to view, while event binding flows data from view to component.

How do you inject a service into an Angular component?

You inject a service by declaring it as a parameter in the component's constructor and marking it as private or public, for example: constructor(private userService: UserService) {}. Angular's DI system provides the instance automatically.

What is an observable, and how is it used in Angular?

An observable is a stream of asynchronous data that you can subscribe to. In Angular, observables are used for things like HTTP requests or form value changes, allowing you to react to new data over time.

What is the purpose of the async pipe in Angular templates?

The async pipe subscribes to an observable or promise and automatically updates the view with the latest value. It also handles unsubscribing when the component is destroyed, preventing memory leaks.

Intermediate questions

Explain the difference between reactive forms and template-driven forms. When would you use each?

Reactive forms are defined in TypeScript and use explicit form controls, making them more scalable, testable, and suitable for complex validation or dynamic forms. Template-driven forms are simpler, using directives in the template, and are best for basic forms with minimal logic.

How do you prevent memory leaks when subscribing to observables in Angular components?

I either unsubscribe manually in the ngOnDestroy lifecycle hook or use the async pipe in templates. For multiple subscriptions, I often use the takeUntil operator with a subject that emits on destroy.

What does the OnPush change detection strategy do, and when should you use it?

OnPush tells Angular to check a component only when its inputs change by reference, or when an event occurs inside the component. It's ideal for performance optimization, especially in large apps or when using immutable data.

How do you implement route guards in Angular, and what are common use cases?

You implement a guard by creating a service that implements interfaces like CanActivate or CanLoad, and returning a boolean or observable. Common use cases include protecting routes from unauthorized access or checking if data is loaded before navigation.

How does Angular's HttpClient handle HTTP requests and responses?

HttpClient makes HTTP requests and returns observables. You can subscribe to these observables to get the response, and use RxJS operators to transform or handle errors. It also supports interceptors for cross-cutting concerns.

What is the role of TestBed in Angular testing?

TestBed sets up a testing module that mimics the Angular environment, allowing you to declare components, provide services, and configure dependencies for unit and integration tests. It helps isolate what you're testing and ensures consistency.

How do you configure a lazy-loaded module in Angular routing?

You use the loadChildren property in the route definition, pointing to a dynamic import of the module. For example: { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }.

How do you use an HTTP interceptor to add an authentication token to outgoing requests?

You implement the HttpInterceptor interface, clone the request to add the token in the headers, and pass it to next.handle(). This ensures all outgoing requests include the token without modifying each service.

Senior questions

Describe how you would debug a performance issue caused by excessive change detection cycles in a large Angular app.

See the answer in the app, free

How would you design a shared authentication service that works across lazy-loaded modules and standalone components?

See the answer in the app, free

What are the trade-offs between using RxJS observables and Angular signals for component state?

See the answer in the app, free

How would you test an Angular component that depends on a service making HTTP requests?

See the answer in the app, free

How can you share data and state between sibling components that are part of different lazy-loaded modules?

See the answer in the app, free

More Frontend topics