Sub topic 1
What Angular DevTools does and where it fits
Angular DevTools is a browser extension that adds Angular-aware panels to your browser's developer tools. The built-in Elements and Console panels show you DOM nodes and JavaScript values. Angular DevTools shows you the framework's view of the same page: components, their state, the injectors behind them, and how long change detection takes.
This chapter explains what the extension does, how it differs from the tools you already use, and when to reach for it. Later chapters cover installation and each panel in detail.
Prerequisites
This chapter assumes you have:
- Basic Angular knowledge: components, templates, and services.
- Familiarity with TypeScript.
- Experience with browser developer tools such as the Elements and Console panels.
- A running Angular app served in development mode, which you will need from the next chapter onward.
What the extension gives you
Angular DevTools adds two main tabs to the browser's developer tools window.
- Components shows the component tree of the page. You can select a component, read its inputs, outputs, and properties, edit values, and jump to its source. The same tab also lets you inspect dependency injection and the router tree.
- Profiler records change detection cycles. It reports how long each cycle took and which components were checked, so you can find the ones that cost the most.
The Elements panel can only show you the rendered DOM. A component such as <app-report> appears there as a custom element with some child nodes. The class instance that produced those nodes is not visible. Angular DevTools lets you select that instance and read its fields directly.
Where it fits among your other tools
Angular DevTools does not replace the other tools. It answers a different question from each of them.
| Tool | Question it answers |
|---|---|
| Elements panel | What DOM and styles are on the page? |
| Console and `ng` utilities | What is this one value right now? Can I run a quick command? |
| Sources panel and breakpoints | What happens line by line when this code runs? |
| Network panel | What did the app request and receive? |
| Angular DevTools | Which components exist, what state do they hold, and which of them make change detection slow? |
A useful rule: use Angular DevTools when the problem is about the structure or timing of the Angular app, and use a general tool when the problem is about a single line of code or a network call.
Typical problems it helps with
Three situations come up often.
- A template shows the wrong value. You select the component in the tree and compare its actual property values with what you expected. This tells you whether the bug is in the data or in the template.
- A service behaves differently in two places. You inspect the injectors for each component and see which provider each one received.
- The page stutters when data changes. You record a profile and look for components that are checked often or take a long time. A component like the one below is a typical finding. It calls a costly method from its template, so the method runs for every row on every change detection pass.
import { Component } from '@angular/core';
@Component({
selector: 'app-report',
standalone: true,
template: `
@for (row of rows; track row.id) {
<p>{{ row.name }}: {{ expensiveTotal(row) }}</p>
}
`,
})
export class ReportComponent {
rows = Array.from({ length: 500 }, (_, i) => ({ id: i, name: `Row ${i}`, values: [i, i + 1, i + 2] }));
// Called for every row on every change detection pass.
expensiveTotal(row: { values: number[] }): number {
let total = 0;
for (let n = 0; n < 100000; n++) {
total += row.values[n % row.values.length];
}
return total;
}
}The profiler makes this kind of problem visible as long change detection cycles. You will record and read such a profile in later chapters, then fix it with OnPush.
Limits to know about
The extension also reads the page as it is at the moment you look. It is not a recorder of past state, apart from the profiler, which captures only what happens while a recording is running.
How the rest of the tutorial is organized
The next chapters follow the order in which you will usually use the tool: install it, explore the component tree, inspect and edit state, learn the change detection background, profile and fix a slow component, and then cover injectors, the router tree, and the ng console utilities. The last chapter combines these into one debugging workflow.
Exercise
You see a list item rendering the wrong label in your running Angular app. The Elements panel shows the correct markup for the wrong text. Which Angular DevTools tab do you use first, and what do you compare there?
Show answer
Use the Components tab. Select the component that renders the item and compare its actual property and input values with what you expect. If the values are wrong, the bug is in the data or in the parent passing it. If the values are correct, the bug is in the template.
Exercise
A page feels slow only when a large list updates. Which tab do you use, and why is the Elements panel not enough?
Show answer
Use the Profiler tab. The Elements panel shows only the resulting DOM, not how long change detection took or which components were checked. The profiler records each cycle and shows which components are costly.