All questions
Showing of 95What are the main building blocks of an Angular application?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
An Angular application is built from components, each a TypeScript class for the logic plus an HTML template for one part of the screen. Other blocks support them:
- Services hold logic not tied to a view. With dependency injection, Angular creates a service and passes it to each component that asks.
- Directives add behavior to DOM elements.
- Pipes transform data for display.
- Guards control navigation and access to routes.
- Interceptors read or change HTTP requests and responses.
NgModules can still group code, but components are standalone by default, so NgModules are optional.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is TypeScript and why does Angular use it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
TypeScript is a superset of JavaScript, so any JavaScript syntax is also legal TypeScript. It adds static typing, so the compiler checks types before the code runs.
Angular uses it because:
- Type errors appear at compile time instead of runtime.
- Editors use the types for autocomplete, refactoring and navigation.
- Interfaces and access modifiers build on classes and inheritance for object-oriented code.
- ES6 and later features compile down to older JavaScript.
- In a large codebase, a changed type flags every line that breaks.
- Error messages name the expected type, so debugging is faster.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between a framework and a library? Is Angular a framework or library?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The difference is who controls the flow. A library is a collection of functions that your code calls, so you decide when to use it. A framework provides the structure and calls your code, a principle called inversion of control.
Angular is a framework.
- Provides the application structure and architecture, and controls the flow through the component lifecycle.
- Its dependency injection manages object creation, so your code does not create its own dependencies.
- Ships built-in features such as routing, forms and an HTTP client.
- Expects your code to follow its conventions and patterns.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a component in Angular? How do you create one?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A component controls one part of the screen, called a view. It has four parts:
- A TypeScript class that holds the application logic.
- An HTML template that defines the view.
- CSS styles that define its appearance.
- Metadata from the
@Componentdecorator, which tells Angular how to process the class.
To create one, run ng generate component example or write the class by hand.
import { Component } from '@angular/core';
@Component({
selector: 'app-example',
template: '<h1>{{title}}</h1>',
styleUrls: ['./example.component.css']
})
export class ExampleComponent {
title = 'Hello World';
}
The selector is the tag other templates use, here <app-example>. Components are standalone by default, so another component uses this one by adding ExampleComponent to its imports array.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the purpose of the @Component decorator?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The @Component decorator marks a class as an Angular component and attaches the metadata Angular uses to create and render it. Its options include:
selector: the CSS selector that identifies the component in templates.templateortemplateUrl: the HTML, inline or in a separate file.stylesorstyleUrls: the component's CSS.imports: the components, directives and pipes its template uses.providers: services for the component, its children and projected content.viewProviders: services visible only inside its own view, hidden from projected content.encapsulation: whether the component's styles stay scoped to it.changeDetection: when Angular checks the component's view for changes.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the difference between template and templateUrl
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
template holds a component's HTML inline as a string inside the decorator, while templateUrl points to a separate HTML file.
@Component({
selector: 'app-example',
template: '<h1>{{title}}</h1><p>Inline template</p>'
})
@Component({
selector: 'app-example',
templateUrl: './example.component.html'
})
Use template for simple, short templates, where the markup is easier to read next to the class. Use templateUrl for complex templates, because a separate file gets HTML syntax highlighting and keeps the class file organized.
The choice does not change how the app runs. The ahead-of-time (AOT) compiler inlines external templates into the JavaScript at build time.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are the different types of data binding in Angular?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Angular supports four types of data binding, and they differ in which way the data flows.
- Interpolation shows a component value as text in the template. Data flows one way, from component to template.
<h1>{{title}}</h1>
- Property binding sets a property of an element, such as
srcordisabled, from a component value. It also flows from component to template.
<img [src]="imageUrl">
<button [disabled]="isDisabled">
- Event binding calls a component method when the template raises an event. Data flows one way, from template to component.
<button (click)="onClick()">Click me</button>
- Two-way binding combines property and event binding, so a change on either side updates the other. Using it with
ngModelneedsFormsModule.
<input [(ngModel)]="username">
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the difference between interpolation and property binding
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Both put component data into the template, but interpolation always converts the value to a string, while property binding passes the value with its type.
Interpolation uses double curly braces, {{ }}.
<h1>Welcome {{userName}}</h1>
<img src="{{imageUrl}}">
Property binding puts the element property in square brackets, such as [src].
<h1 [textContent]="userName"></h1>
<img [src]="imageUrl">
Inside an attribute, Angular treats interpolation as a property binding, so both img lines do the same thing. Use property binding for non-string properties, such as a boolean, a number or an object.
Neither syntax is more secure. Angular treats every bound value as untrusted, and it sanitizes and escapes values from template bindings and interpolation alike.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is event binding and how do you pass data with events?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Event binding runs a component method when the user acts on an element, such as a click, a key press or a mouse movement. You write the event name in parentheses and the statement to run in quotes.
<button (click)="onClick()">Click me</button>
<input (keyup)="onKeyUp()">
To pass data, give the method $event, which holds the DOM event object. The handler can then read details such as the input's current value. You can also pass any template value, such as (click)="select(item)".
<input (keyup)="onKeyUp($event)">
<button (click)="onClick($event)">Click</button>
onKeyUp(event: any): void {
console.log(event.target.value);
}
onClick(event: Event): void {
console.log('Button clicked');
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are directives in Angular? What are the different types?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Directives are classes that add behavior to elements in Angular templates. There are three types:
- Components are directives with their own template.
- Structural directives change the DOM layout by adding or removing elements.
- Attribute directives change the appearance or behavior of an element.
<!-- Structural Directives -->
<div *ngIf="condition">Content</div>
<li *ngFor="let item of items">{{item}}</li>
<!-- Attribute Directives -->
<div [ngClass]="cssClass">Content</div>
<div [ngStyle]="styleObject">Content</div>
NgIf and NgFor are deprecated since Angular 20, because the built-in @if and @for blocks now do their job. They still show how a structural directive works. For styling, the style guide prefers plain class and style bindings over ngClass and ngStyle.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the ngIf, ngFor and ngSwitch directives
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
ngIf and ngFor are structural directives, which add or remove elements in the DOM. ngSwitch is an attribute directive that works with the structural ngSwitchCase and ngSwitchDefault.
*ngIf includes or removes an element based on a condition, with an optional else template.
<div *ngIf="isVisible">This will show conditionally</div>
<div *ngIf="user; else noUser">Welcome {{user.name}}</div>
<ng-template #noUser>Please log in</ng-template>
*ngFor repeats an element for each item in a collection. index as i exposes the position. trackBy tells Angular how to match items when the list changes, so it can reuse their DOM elements.
<li *ngFor="let item of items; index as i; trackBy: trackByFn">
{{i}}: {{item.name}}
</li>
ngSwitch displays one element out of several. You bind it as [ngSwitch] on a container. Each *ngSwitchCase child renders only when its value matches, and *ngSwitchDefault renders when none does.
<div [ngSwitch]="condition">
<p *ngSwitchCase="'A'">Case A</p>
<p *ngSwitchCase="'B'">Case B</p>
<p *ngSwitchDefault>Default case</p>
</div>
All three have been deprecated since Angular 20 in favor of the built-in control flow blocks @if, @for and @switch. A @for block takes a track expression that identifies each item, so it can reuse views.
@if (user) {
<div>Welcome {{user.name}}</div>
} @else {
<p>Please log in</p>
}
@for (item of items; track item.id; let i = $index) {
<li>{{i}}: {{item.name}}</li>
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a service in Angular and when would you use one?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A service is a class with a specific purpose that provides functionality not tied to a view, so many components can share it. Use one for:
- Sharing data between components.
- Business logic that should not live in components.
- External communication, such as HTTP requests.
- Utility functions and helpers.
- State management.
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DataService {
private data: string[] = [];
getData(): string[] {
return this.data;
}
addData(item: string): void {
this.data.push(item);
}
}
providedIn: 'root' creates one shared instance for the whole app, and the build drops the service if nothing uses it. Components receive that instance through dependency injection. Newer Angular versions also offer @Service(), a shorter way to declare the same root-provided singleton.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you inject one service into another?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A service declares what it needs, and Angular's injector supplies it. With constructor injection, you list the other service as a constructor parameter.
@Injectable({
providedIn: 'root'
})
export class LoggerService {
log(message: string): void {
console.log(message);
}
}
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor(private logger: LoggerService) {}
getData(): any[] {
this.logger.log('Getting data...');
return [];
}
}
Angular reads the parameter type, finds the provider for LoggerService, and passes the instance in when it creates DataService. Both services are root-provided, so the whole app shares one logger.
The style guide now prefers the inject() function, which reads better when a class has many dependencies. You write private logger = inject(LoggerService); in a field initializer or call it in the constructor.
Avoid circular dependencies, where service A depends on service B and service B depends on A as well. Angular cannot create either one and throws an error.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is Angular Router and how do you configure routes?
What is FormBuilder and why would you use it?
How do you make HTTP requests in Angular?
When would you use ngOnChanges vs ngOnInit?
What are pipes in Angular and how do you use them?
What is Angular CLI and what are its main features?
What is the difference between the constructor and ngOnInit?
Explain the Angular architecture and its key components
What is component communication and what are the different ways to achieve it?
What are lifecycle hooks? Name the most commonly used ones
What is two-way data binding and how does it work?
What is the difference between ngIf and hidden?
How do you create a custom directive?
What are structural directives and how do they work?
What is Dependency Injection and how does it work in Angular?
What are the different ways to provide a service in Angular?
What is the difference between providedIn: 'root' and registering in providers array?
What are route parameters and how do you access them?
What are query parameters and how do they differ from route parameters?
What are route guards and what types are available?
How do you implement lazy loading in Angular?
What are the differences between template-driven and reactive forms?
How do you implement form validation in Angular?
How do you create custom validators?
How do you handle HTTP errors in Angular?
What are HTTP interceptors and how do you use them?
How do you implement request and response transformation?
How do you handle loading states during HTTP requests?
What are Observables and why does Angular use them?
What is the difference between Observable and Promise?
How do you handle subscription management to prevent memory leaks?
What are the most commonly used RxJS operators?
Explain the complete component lifecycle and when each hook is called
What is the purpose of ngAfterViewInit and ngAfterContentInit?
How do you properly clean up resources in ngOnDestroy?
How do you create a custom pipe?
What is the difference between pure and impure pipes?
How do you handle asynchronous data with pipes?
Can you create a pipe that filters an array? Is it recommended?
How do you unit test Angular components?
How do you test services with dependencies?
How do you test components with inputs and outputs?
How do you test Angular applications end-to-end?
How do you customize the Angular CLI build process?
How do you configure different environments in Angular CLI?
What is Angular Ivy and what are its benefits?
What are standalone components in Angular?
How do you implement content projection with multiple slots?
What is the difference between AOT and JIT compilation in Angular?
What does the @defer block do, and how is it different from route-level lazy loading?
When would you use a signal instead of an RxJS Observable?
What is the difference between switchMap, mergeMap, concatMap and exhaustMap?
What is the difference between Subject, BehaviorSubject and ReplaySubject?
What is the difference between ng-content, ng-template and ng-container?
What is a route resolver, and when would you use one instead of fetching in ngOnInit?
How do signal inputs and outputs differ from the @Input and @Output decorators?
How do you handle multiple HTTP requests with different patterns?
What are the different change detection strategies?
How do you test HTTP interceptors?
How do you optimize large lists and implement virtual scrolling?
What are signals in Angular?
How do you handle dynamic forms in Angular?
How does Angular's change detection work?
When and how would you manually trigger change detection?
What is Zone.js and how does it relate to change detection?
How can you optimize change detection performance?
What are the best practices for testing Angular applications?
What are the main performance bottlenecks in Angular applications?
What is OnPush change detection strategy and when should you use it?
What are some techniques for reducing bundle size?
What is Angular Universal and how does it work?
What are Angular Elements and how do you create them?
How do you implement internationalization (i18n) in Angular?
What are Angular Schematics and how do you create custom ones?
How do you implement micro-frontends with Angular?
What are the main security considerations in Angular applications?
How do you implement authentication and authorization in Angular?
How do you secure HTTP communications?
How do you handle sensitive data in Angular applications?
What are Angular's built-in security features?
What are Angular CLI builders and how do you create custom ones?
How do you implement server-side rendering (SSR) in Angular?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Angular in pictures.
A quick recap of Angular in 33 short animated pictures, one idea at a time. About 9 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 31 pictures come with Pro.
Angular cheatsheet
- Components & templates01
- Control flow & directives02
- Inputs, outputs & lifecycle03
- Services & DI04
- Routing & lazy loading05
- Forms06
- HTTP & RxJS07
- Signals & change detection08
- CLI, build & test09
- SSR, i18n & security10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 31 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in82 of 95 Angular answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.