Angular Basics
Angular Basics Interview with follow-up questions
1. What is Angular and why is it used?
Angular is an open-source, TypeScript-first framework developed by Google for building single-page applications (SPAs) and large-scale web apps. It gives you an opinionated, batteries-included platform: a component model, dependency injection, a router, an HTTP client, forms, and a powerful CLI — so teams get consistency and structure out of the box.
A common 2026 gotcha: don't describe Angular as an "MVC framework" — that's AngularJS-era language. Modern Angular is component-based and increasingly signal-based. Interviewers want to hear that you know the current model: standalone components (the default since v17), signals for fine-grained reactivity (stable since v20), the built-in control flow (@if/@for/@switch), and zoneless change detection (default for new apps in v21+). The latest stable release is Angular 22 (June 2026). Saying "Angular uses NgModules and *ngIf" signals stale knowledge.
Follow-up 1
Can you explain how Angular differs from other JavaScript frameworks?
Angular differs from other JavaScript frameworks in several ways:
Two-way data binding: Angular provides two-way data binding, which means any changes made to the model are automatically reflected in the view, and vice versa. This simplifies the process of keeping the UI in sync with the underlying data.
Dependency injection: Angular has a built-in dependency injection system, which makes it easy to manage dependencies between different components of an application. This promotes code reusability and modularity.
Directives: Angular allows the creation of custom directives, which are reusable components that can be used to extend HTML with new functionality. This enables developers to create their own HTML tags and attributes, making the code more expressive and readable.
Testing: Angular provides built-in support for unit testing, which makes it easier to write testable code and ensure the quality of the application.
These are just a few examples of how Angular differs from other JavaScript frameworks.
Follow-up 2
What are some key features of Angular?
Some key features of Angular include:
Two-way data binding: Angular provides two-way data binding, which allows changes in the model to automatically update the view, and vice versa.
Component-based architecture: Angular follows a component-based architecture, where the application is divided into reusable components. This promotes code reusability and modularity.
Dependency injection: Angular has a built-in dependency injection system, which makes it easy to manage dependencies between different components of an application.
Directives: Angular allows the creation of custom directives, which are reusable components that can be used to extend HTML with new functionality.
Templating: Angular provides a powerful templating system that allows developers to define the structure and layout of the application's UI.
Routing: Angular has a built-in router that allows developers to define the navigation paths of the application.
These are just a few examples of the key features of Angular.
Follow-up 3
Why would you choose Angular over other frameworks?
There are several reasons why one might choose Angular over other frameworks:
Large community and ecosystem: Angular has a large and active community of developers, which means there are plenty of resources, tutorials, and libraries available to help with development.
Comprehensive documentation: Angular has comprehensive and up-to-date documentation, which makes it easier to learn and use.
Two-way data binding: Angular provides two-way data binding, which simplifies the process of keeping the UI in sync with the underlying data.
Component-based architecture: Angular follows a component-based architecture, which promotes code reusability and modularity.
Built-in tools and features: Angular provides a set of built-in tools and features, such as dependency injection, routing, and testing support, which make it easier to develop and maintain applications.
These are just a few reasons why one might choose Angular over other frameworks.
2. Can you explain the basic architecture of an Angular application?
A modern Angular app is built from a tree of components, supported by services and dependency injection. Each component pairs a TypeScript class with an HTML template and styles, and renders a slice of the UI. Components compose and communicate via inputs/outputs (or, increasingly, signal inputs and the model() API).
The pieces interviewers expect you to name:
- Components — the building blocks. Since Angular 17 they're standalone by default, declaring their own
importsdirectly, soNgModuleis now optional/legacy boilerplate. - Templates + binding — declarative HTML with interpolation, property/event binding, and the new built-in control flow (
@if,@for,@switch). - Services & DI — reusable logic (data access, state) injected via
inject()or the constructor, typicallyprovidedIn: 'root'. - Bootstrapping — apps start with
bootstrapApplication(AppComponent, { providers: [...] })plusprovideRouter,provideHttpClient, etc., rather than the oldAppModule. - Routing — lazy-loaded routes with
loadComponent.
The follow-up is usually "how has this changed?" — be ready to contrast this standalone, signal-driven setup with the older NgModule-centric architecture.
Follow-up 1
What is the role of a component in Angular?
In Angular, a component is responsible for rendering the user interface and handling user interactions. Components are reusable and encapsulate both the UI and the logic associated with it. They are the building blocks of an Angular application.
A component consists of three main parts:
Template: The template defines the structure and layout of the UI. It is written in HTML and can include Angular-specific syntax for data binding, event handling, and other features.
Class: The class contains the logic and data associated with the component. It is written in TypeScript and can include properties, methods, and lifecycle hooks.
Metadata: The metadata is defined using decorators and provides additional information about the component, such as its selector, styles, and dependencies.
Components can communicate with each other using input and output properties. They can also use services to fetch data or perform other operations.
Follow-up 2
What is a module in Angular?
In Angular, a module is a container for different components, services, and other features. It provides a way to organize and manage the different parts of an application.
A module is defined using the @NgModule decorator. It specifies the components, services, and other dependencies that are part of the module. It also defines the module's imports, exports, and providers.
Modules help to keep the codebase organized and promote modularity and reusability. They allow for lazy loading, which means that modules can be loaded on-demand as the user navigates through the application. Modules also enable dependency injection, which is a key feature of Angular.
Follow-up 3
How do services fit into the Angular architecture?
Services play a crucial role in the Angular architecture. They are responsible for providing data and functionality that can be shared across multiple components.
Services are typically used to handle data fetching, business logic, and other operations that are not directly related to the UI. They encapsulate the logic and provide a way to separate concerns and promote reusability.
Services can be injected into components and other services using dependency injection. This allows components to use the services without having to create instances of them manually. Dependency injection also makes it easier to test and maintain the code.
To create a service in Angular, you can use the @Injectable decorator. This decorator marks the class as a service and allows it to be injected into other parts of the application.
Overall, services help to keep the codebase modular, maintainable, and scalable.
3. What is data binding in Angular?
Data binding keeps a component's data and its template in sync, so you describe the UI declaratively instead of manually touching the DOM. Angular has four forms, usually grouped as:
- Interpolation —
{{ value }}renders data into the template. - Property binding —
[src]="url"sets element/component properties (one-way, class → view). - Event binding —
(click)="save()"reacts to user/DOM events (view → class). - Two-way binding —
[(ngModel)]="name"(the "banana-in-a-box"), combining property and event binding.
A current follow-up worth pre-empting: how the reactivity underneath has changed. Traditionally Angular re-evaluated bindings via Zone.js-driven change detection. In modern Angular, signals drive fine-grained updates and zoneless change detection (default in new v21+ apps) updates only the views that actually depend on changed state — so binding the value of a signal() is now idiomatic.
Follow-up 1
Can you differentiate between one-way and two-way data binding?
One-way data binding is a type of data binding where the data flows only from the component to the view. It means that any changes in the component will be reflected in the view, but not vice versa. This is achieved using interpolation ({{ }}) or property binding ([ ]).
Two-way data binding, on the other hand, allows the data to flow both from the component to the view and from the view to the component. It means that changes in the component will be reflected in the view, and changes in the view will also update the component. This is achieved using the [( )] syntax, also known as banana-in-a-box syntax.
Follow-up 2
What is event binding?
Event binding in Angular is a type of data binding that allows you to listen to events triggered by the user, such as button clicks, mouse movements, or keyboard inputs. It enables you to respond to these events by executing a function or performing some action in the component. Event binding is achieved using the ( ) syntax, followed by the event name and the function to be executed.
Follow-up 3
How does property binding work in Angular?
Property binding in Angular is a type of data binding that allows you to set the value of an HTML element property based on the value of a component property. It enables you to dynamically update the properties of HTML elements based on the state of the component. Property binding is achieved using the [ ] syntax, followed by the property name and the component property to bind to.
4. What is a directive in Angular?
A directive is a class that adds behavior to elements in the template. Angular has three kinds:
- Components — directives with a template; the most common kind.
- Attribute directives — change the appearance or behavior of an element (e.g.
ngClass,ngStyle, or a custom[highlight]). - Structural directives — change DOM layout by adding/removing elements (historically
*ngIf,*ngFor,*ngSwitch).
The key 2026 update: the legacy structural directives *ngIf/*ngFor/*ngSwitch have been superseded by the built-in control flow @if/@for/@switch (default since Angular 17), which needs no imports and is faster. They still work but new code should use the block syntax. Also note Angular 17.1+ supports directive composition (hostDirectives) so a component can apply other directives' behavior without inheritance.
Follow-up 1
Can you give an example of a built-in directive?
Sure! One example of a built-in directive in Angular is the ngIf directive. This directive is used to conditionally render elements in the DOM based on a given expression. Here's an example:
<div>This element will only be displayed if the 'showElement' variable is true.</div>
Follow-up 2
How would you create a custom directive?
To create a custom directive in Angular, you can use the @Directive decorator. Here's an example of how you can create a directive that changes the background color of an element:
import { Directive, ElementRef, Renderer2 } from '@angular/core';
@Directive({
selector: '[appHighlight]'
})
export class HighlightDirective {
constructor(private el: ElementRef, private renderer: Renderer2) {
this.renderer.setStyle(this.el.nativeElement, 'background-color', 'yellow');
}
}
In this example, the appHighlight directive will change the background color of any element that has the appHighlight attribute.
Follow-up 3
What is the difference between a component and a directive?
In Angular, a component is a type of directive with a template. It is used to create reusable UI components that encapsulate both the behavior and the view. On the other hand, a directive is a class that allows you to attach behavior to elements in the DOM, but it does not have a template of its own. Directives are typically used to extend HTML with new attributes and elements, or to modify the behavior of existing elements.
5. Can you explain how Angular handles user input?
Angular captures user input through event binding and reflects state back with property/two-way binding. You listen for DOM events with the (event) syntax and handle them in the class:
Save
The $event object gives you the native event (or a component's emitted value). For forms, you reach for either two-way binding with [(ngModel)] (template-driven) or reactive forms (FormControl/FormGroup) for more control and typed values.
A modern framing interviewers like: in signal-based components you often bind an `'s value to asignal()and update it in the handler, or use the **model()** API for two-way-bindable signal inputs — giving the same UX as[(ngModel)]` without Zone.js-driven change detection.
Follow-up 1
How would you capture user input from a form?
To capture user input from a form in Angular, you can use the ngModel directive. The ngModel directive provides two-way data binding for form controls, allowing you to bind a form control to a property in your component. Here's an example:
In this example, the value entered in the input field will be automatically bound to the name property in your component. Any changes to the name property will also be reflected in the input field.
Follow-up 2
What is the role of ngModel?
The ngModel directive in Angular is used for two-way data binding with form controls. It allows you to bind a form control to a property in your component, so that any changes to the form control are automatically reflected in the component property, and vice versa. ngModel also provides additional features like form validation and error handling.
Follow-up 3
How does Angular handle form validation?
Angular provides built-in form validation features that allow you to validate user input in forms. You can use the ngModel directive along with various validation directives to perform validation. For example, you can use the required directive to make a form control required, or the pattern directive to enforce a specific pattern for the input. Angular also provides a FormGroup and FormControl classes that you can use to create more complex form validations. Additionally, Angular provides CSS classes and error messages that can be used to display validation errors to the user.
Live mock interview
Mock interview: Angular Basics
- Read your scene and goals
- Talk it out; goals tick off live
- Get a score and stronger lines
Your voice and your AI key never touch our servers; the key stays in this browser and is sent only to Google. Only your round scores are saved to track progress.