Sub topic 1
What Angular DevTools does and where it fits
Angular DevTools is a browser extension that adds Angular-aware panels to the browser's developer tools. The Elements panel shows you DOM nodes. Angular DevTools shows you the components, directives, injectors, and routes that produced those nodes. This chapter explains what the extension can and can't tell you, how it gets its data, and when to use it instead of other tools. Later chapters cover each feature in detail.
Prerequisites
This chapter assumes you have:
- Basic Angular knowledge: components, templates, and services.
- Familiarity with TypeScript.
- Experience with the Elements and Console panels of your browser's developer tools.
- An Angular app you can serve in development mode, for example with
ng serve.
You don't need prior profiling experience. Change detection gets its own background chapter before we use the profiler.
What the extension gives you
Angular DevTools has two main areas and a few smaller inspectors.
| Area | What it shows | Typical question it answers |
|---|---|---|
| Components | The component and directive tree, with each instance's properties, inputs, and outputs | "What state does this component hold right now?" |
| Profiler | Recordings of change detection cycles, broken down by component | "Which components make rendering slow?" |
| Injector tree | The injector hierarchy and the providers each injector holds | "Where does this service instance come from?" |
| Router tree | The configured routes and the active route | "Which route configuration matched this URL?" |
The Components panel is where most debugging sessions begin. You can select a component, read its state, edit a value, and jump to its source. The Profiler is the only part of the extension that measures time. Use it for performance questions, and use the Components panel for questions about structure and state.
Availability of the injector and router panels depends on the extension version and the Angular version of your app. Check the extension's release notes if a panel is missing.
How it works
The extension doesn't read your TypeScript source or your bundles. It talks to the running page. In development mode, Angular exposes debugging hooks on the page: the ng global object and the metadata Angular attaches to DOM nodes. The extension's content script reads those hooks and sends the results to the DevTools panel.
flowchart LRThe diagram below shows the path.
Two consequences follow from this design.
- It describes what exists at runtime, not what the source says. If a component is created conditionally or lazily, it appears in the tree only when it exists on the page.
- It depends on development-mode APIs. Production builds strip or disable these hooks, so the extension has nothing to read.
Development mode only
Angular DevTools needs a development build. If you open it on a production site, it reports that it can't detect an Angular application, or that the app was built for production. This is expected behavior, not a bug.
You can check the mode from your own code with isDevMode():
import { isDevMode } from '@angular/core';
console.log(isDevMode() ? 'Development mode: DevTools can attach' : 'Production mode');You can also check from the browser console on the page you are debugging:
// Defined in development builds; typically undefined in production builds.
console.log(typeof ng !== 'undefined' ? 'ng global present' : 'ng global missing');Where it fits among other tools
Angular DevTools doesn't replace your other debugging tools. Each answers a different kind of question.
| Tool | Best for | Weak spot |
|---|---|---|
| Angular DevTools | Component structure, component state, injector and route inspection, change detection cost per component | Doesn't show network traffic, memory, or non-Angular code |
| Browser Elements panel | DOM structure, CSS, layout | Doesn't know about components or their state |
| Browser Performance panel | Whole-page timing, scripting vs rendering vs painting, long tasks | Shows function names from your bundle, not components |
| Browser Network panel | HTTP requests, caching, payload size | Doesn't relate requests to components |
| Debugger and breakpoints | Stepping through logic line by line | Slow for understanding overall structure |
| `console.log` and `ng` utilities | Quick, targeted checks and scripting | Manual, and easy to leave behind in the code |
A practical rule: start with Angular DevTools when your question is phrased in Angular terms ("which component", "which injector", "which route"). Move to a general browser tool when the question is about the network, memory, layout, or the cost of non-Angular code.
The two profilers complement each other. The Angular profiler tells you which component's change detection took the time. The browser's Performance panel tells you what the browser spent the time on, including work outside change detection such as layout and painting. A slow interaction can be slow for reasons the Angular profiler never sees.
A first look at a running app
Here is a minimal component you can serve with ng serve and inspect.
import { Component, input, output, signal } from '@angular/core';
@Component({
selector: 'app-counter',
standalone: true,
template: `
<p>{{ label() }}: {{ count() }}</p>
<button (click)="increment()">Add</button>
`,
})
export class CounterComponent {
label = input('Clicks');
changed = output<number>();
count = signal(0);
increment() {
this.count.update((n) => n + 1);
this.changed.emit(this.count());
}
}With this component on the page, the Components panel lists app-counter as a node in the tree. Selecting it shows label as an input, changed as an output, and count as a property on the instance. This example uses the signal-based input() and output() functions, so it needs an Angular version that provides them. The chapter on inspecting state covers how DevTools displays each kind of property.
You will build on this view in later chapters. For now, confirm that you can find the node and that you understand where its data comes from.
What it won't show
Knowing the limits saves time.
- Templates that are not instantiated. A component inside a closed
@ifblock has no instance, so it has no node. - Production behavior. Timings in development mode include extra checks, so absolute numbers are higher than in production. Compare relative differences between recordings made in the same mode, not absolute values against production metrics.
- Non-Angular code. Third-party widgets that manage their own DOM show up as plain elements.
- Applications on unsupported Angular versions. The extension requires a reasonably recent Angular release built on the Ivy renderer. Check the extension's listing for the exact minimum version.
- Browsers without extension support. The extension is published for Chromium-based browsers and Firefox. Other browsers may not be able to install it.
Common mistakes
- Profiling a production build. The panel stays empty or reports no Angular app. Rebuild in development mode.
- Treating development timings as production numbers. Use them to rank components and compare before and after, not to predict real-world milliseconds.
- Debugging the wrong page. With multiple tabs or iframes, the DevTools panel is attached to the tab you opened it in. Confirm the URL.
- Editing state and expecting it to persist. Changes made through the panel affect the running instance only. A reload resets them, and the source code is unchanged.
- Reaching for the profiler first. If a bug is about wrong data, not slowness, inspect state before profiling.
How the rest of the tutorial uses it
The chapters that follow move from structure to measurement:
- Install the extension and confirm detection.
- Explore the component tree and inspect state.
- Edit values at runtime and jump to source.
- Learn the change detection background, then record and read profiler sessions.
- Apply
OnPushand verify the improvement with a new profile. - Inspect injectors, routes, and the
ngconsole utilities. - Combine everything in one workflow.
Exercise
You open Angular DevTools on your company's live website and it reports that no Angular application was detected. The site is built with Angular. What is the most likely cause, and what should you do to investigate a component bug on it?
Show answer
The site is a production build, which doesn't expose the development-mode debugging APIs the extension reads. Reproduce the bug locally with a development build (for example with ng serve) and inspect it there. For timing questions on the live site, use the browser's Performance panel instead.
Exercise
A page feels slow after a click. You suspect Angular change detection but you also see long "Rendering" and "Painting" segments in the browser's Performance panel. Which tool can account for each part of the delay?
Show answer
The Angular DevTools profiler can attribute change detection time to individual components. It can't see browser rendering and painting, which the browser's Performance panel shows. You need both to account for the whole delay.