All interview guides

Angular Interview Questions and Answers

24 questions that come up in Angular technical interviews, each with the answer and an explanation of why it is right.

Test yourself — 90 question bank

1. What is Angular?

Beginner

Answer: A TypeScript-based web application framework

Angular is a TypeScript-based open-source web application framework developed and maintained by Google. It is used for building single-page applications (SPAs).

2. What is Angular Router?

Intermediate

Answer: Both b and c

Angular Router enables navigation between views/components in a single-page application. It maps URL paths to components and manages navigation history.

3. What is NgRx?

Advanced

Answer: Both b and c

NgRx is a state management library that implements the Redux pattern using RxJS. It provides a single source of truth for application state.

4. How do you define routes in Angular?

Intermediate

Answer: All of the above

Routes are defined as an array of Route objects in the routing module. Each route specifies a path and the component to display.

5. Which command creates a new Angular project?

Beginner

Answer: ng new

`ng new project-name` creates a new Angular project with the default configuration, including all necessary files and dependencies.

6. What are the core concepts of NgRx?

Advanced

Answer: All of the above

NgRx core concepts: Store (single state tree), Actions (events), Reducers (pure functions), Effects (side effects), Selectors (state queries).

7. What is a component in Angular?

Beginner

Answer: All of the above

Components are the fundamental building blocks of Angular applications. Each component consists of a TypeScript class, HTML template, and CSS styles.

8. What is a custom directive in Angular?

Advanced

Answer: All of the above

Custom directives allow you to extend HTML with custom behavior. Types: Structural (change DOM layout like *ngIf) and Attribute (change appearance/behavior).

9. What is the router-outlet directive?

Intermediate

Answer: Both b and c

<router-outlet> is a directive that acts as a placeholder where the router should display the routed component based on the current URL.

10. Which decorator is used to define a component?

Beginner

Answer: @Component

The @Component decorator marks a class as an Angular component and provides metadata like selector, template, and styles.

11. What is the routerLink directive used for?

Intermediate

Answer: Both b and c

routerLink is used for navigation between views without full page reload. It generates the appropriate href and handles navigation.

12. What is the difference between @HostListener and @HostBinding?

Advanced

Answer: Both b and c

@HostListener listens to DOM events on the host element. @HostBinding binds host element properties or attributes. Both are used in directives.

13. What is Angular Universal?

Advanced

Answer: Both b and c

Angular Universal enables server-side rendering, generating HTML on the server before sending to client. Improves SEO, initial load time, and social media sharing.

14. What is data binding in Angular?

Beginner

Answer: Synchronization between model and view

Data binding is a mechanism for coordinating parts of a template with parts of a component. Angular supports one-way and two-way data binding.

15. What are route parameters?

Intermediate

Answer: Both b and c

Route parameters are dynamic parts of the URL path. Defined with colon syntax (:id) and accessed via ActivatedRoute service.

16. What is the difference between template-driven and reactive forms?

Intermediate

Answer: Both b and c

Template-driven forms rely on directives in template (ngModel). Reactive forms define form structure in component code, offering better scalability and testability.

17. Which syntax is used for interpolation in Angular?

Beginner

Answer: {{ }}

Double curly braces {{ }} are used for interpolation in Angular templates to display component property values in the view.

18. What is Ahead-of-Time (AOT) compilation?

Advanced

Answer: Both b and c

AOT compiles templates and components during build time (before browser downloads code). Results in faster rendering, better security, and smaller bundle size.

19. Which class is used to create reactive forms?

Intermediate

Answer: All of the above

Reactive forms use FormGroup (group of controls), FormControl (individual field), and FormBuilder (service to easily create forms).

20. What is the purpose of ngModel directive?

Beginner

Answer: Both b and c

ngModel creates two-way data binding between form inputs and component properties. It requires FormsModule to be imported.

21. What is Just-in-Time (JIT) compilation?

Advanced

Answer: All of the above

JIT compiles the application in the browser at runtime. Slower initial load but useful during development for faster builds. AOT is preferred for production.

22. What is tree shaking in Angular?

Advanced

Answer: Both b and c

Tree shaking removes unused code from the final bundle during the build process, reducing bundle size. It works with ES6 module imports.

23. What is the HttpClient service used for?

Intermediate

Answer: All of the above

HttpClient is a service for making HTTP requests to APIs. It returns RxJS Observables and requires HttpClientModule to be imported.

24. What is a module in Angular?

Beginner

Answer: Both b and c

NgModules are containers that group related components, directives, pipes, and services. Every Angular app has at least one module, the root module (AppModule).

Ready to test yourself?

The full Angular bank has 90 questions across 3 difficulty levels — timed, shuffled, and scored.

Take the Angular quiz