Angular Beginner Interview Questions and Answers
Angular beginner interview questions and answers covering components, modules, data binding, directives, services, dependency injection, routing, forms, and RxJS basics.
This page collects the beginner-level Angular questions that come up most often in interviews. Answer each one with a short definition, then back it up with a small example.
Table of Contents
- Core Concepts
- Components and Templates
- Directives and Pipes
- Services and Dependency Injection
- Routing and Forms
- RxJS Basics
Core Concepts
1. What is Angular?
Angular is a TypeScript-based, open-source framework from Google for building single-page web applications. It provides components, dependency injection, routing, forms, an HTTP client and a CLI.
2. What is the difference between AngularJS and Angular?
AngularJS (1.x) is JavaScript-based and uses controllers and $scope. Angular (2+) is a complete rewrite in TypeScript with a component-based architecture, better performance and mobile support.
3. What is TypeScript and why does Angular use it?
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It adds static types, interfaces and decorators, which help catch errors early and improve tooling.
4. What is the Angular CLI?
The Angular CLI is a command-line tool used to create projects, generate code, run a dev server, test and build. For example, ng new, ng generate component, ng serve and ng build.
5. What are the building blocks of an Angular application?
Components, templates, directives, services, pipes, modules (or standalone components) and routing.
Components and Templates
6. What is a component?
A component is the basic UI building block. It combines a TypeScript class, an HTML template and styles, and is declared with the @Component decorator.
@Component({
selector: 'app-hello',
standalone: true,
template: `<h1>Hello {{ name }}</h1>`
})
export class HelloComponent {
name = 'Angular';
}
7. What is a module (NgModule)?
An NgModule groups related components, directives, pipes and services. Newer Angular versions favour standalone components, which do not need an NgModule.
8. What are standalone components?
Components that declare their own dependencies through the imports array instead of belonging to an NgModule.
9. What is data binding, and what are its types?
Data binding connects the component class to the template.
| Type | Syntax | Direction |
|---|---|---|
| Interpolation | {{ value }} |
Component to view |
| Property binding | [property]="value" |
Component to view |
| Event binding | (event)="handler()" |
View to component |
| Two-way binding | [(ngModel)]="value" |
Both |
10. What is the difference between interpolation and property binding?
Interpolation converts the value to a string inside the text. Property binding sets a DOM property directly and keeps the value's type, for example [disabled]="isBusy".
11. What are @Input and @Output?
@Input passes data from a parent to a child component. @Output with an EventEmitter sends events from the child back to the parent.
12. What are lifecycle hooks?
Methods Angular calls at specific moments of a component's life, such as ngOnInit, ngOnChanges, ngAfterViewInit and ngOnDestroy.
13. What is the difference between the constructor and ngOnInit?
The constructor is a TypeScript feature used mainly for dependency injection. ngOnInit runs after Angular has set the inputs, so it is the right place for initialisation logic.
Directives and Pipes
14. What are directives?
Directives add behaviour to elements. There are three kinds: components, structural directives (such as *ngIf, *ngFor) and attribute directives (such as ngClass, ngStyle).
15. What is the difference between *ngIf and [hidden]?
*ngIf adds or removes the element from the DOM. [hidden] keeps the element in the DOM and only hides it with CSS.
16. Why use trackBy with *ngFor?
trackBy gives Angular a stable identity for each item, so it re-renders only the items that changed instead of the whole list.
17. What are pipes?
Pipes transform values in a template, for example {{ price | currency }} or {{ date | date:'short' }}. You can write a custom pipe with the @Pipe decorator.
18. What is the difference between pure and impure pipes?
A pure pipe runs only when its input reference changes. An impure pipe runs on every change detection cycle, which is more expensive.
Services and Dependency Injection
19. What is a service?
A service is a class that holds reusable logic or shared state, such as API calls, and is shared across components through dependency injection.
20. What is dependency injection?
A design pattern where a class receives the objects it needs from an injector instead of creating them itself. It improves testability and reuse.
21. What does providedIn: 'root' mean?
It registers the service as a singleton in the root injector, so one instance is shared across the whole application.
Routing and Forms
22. How does routing work in Angular?
You define an array of routes that map URL paths to components, then render them in a <router-outlet>. Navigation uses routerLink or the Router service.
23. What are route guards?
Guards decide whether navigation is allowed, for example canActivate for authentication and canDeactivate for unsaved changes.
24. What is lazy loading?
Loading a feature's code only when its route is visited. It reduces the initial bundle size and speeds up the first page load.
25. What is the difference between template-driven and reactive forms?
Template-driven forms are defined mostly in the template with ngModel and suit simple cases. Reactive forms are defined in the component class with FormGroup and FormControl, and give more control, testability and scalability.
RxJS Basics
26. What is an Observable?
An Observable is a stream of values over time that you can subscribe to. Angular uses them for HTTP calls, events and forms.
27. What is the difference between an Observable and a Promise?
A Promise handles a single value and runs immediately. An Observable can emit many values, is lazy until subscribed, and can be cancelled.
28. Why unsubscribe from Observables?
To avoid memory leaks from subscriptions that outlive the component. Use takeUntil, takeUntilDestroyed, or the async pipe.
29. What is the async pipe?
A pipe that subscribes to an Observable or Promise in the template and unsubscribes automatically when the component is destroyed.
30. What is change detection?
The mechanism Angular uses to keep the view in sync with component data. With OnPush, a component is checked only when its inputs change or an event occurs in it.
Summary
- Know the building blocks: components, templates, services, directives, pipes and routing.
- Be able to explain data binding, dependency injection and lifecycle hooks with a short example.
- Understand RxJS basics, since Angular uses Observables for HTTP, forms and events.
Was this guide helpful?
CodeWithVenu is free to read, with no paywall. If this guide saved you time or helped you prepare, a small voluntary contribution helps me write more practical tutorials, architecture guides, and interview-prep content.