cd /news/developer-tools/alt-click-any-element-in-your-angula… · home › topics › developer-tools › article
[ARTICLE · art-181368] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

Alt+Click any element in your Angular app and hand its origin to your coding agent

A developer released ng-origin 22.0.0, an MIT-licensed Angular dev-mode library that lets you Alt+Click any element in a running app to copy a plain-text origin block to the clipboard. The block names the declaring app component with file and line, the library component, projection target, template location and search anchors such as translation keys and data-testid, so a coding agent can start editing the right file. The package makes no network requests, redacts secret-shaped strings, and is dropped from production builds.

key takeaway

ng-origin's Alt+Click copies a block naming the app component that declares an element, with file and line, plus library component, projection target and search anchors, giving coding agents the correct edit location; the Template line requires Angular 22.1.4+ with enableTemplateSourceLocations in a

by read3 min views13 publishedDec 3, 2026

Telling a coding agent which button you mean is weirdly hard. "The Archive button on the dashboard" sends it grepping for the label. In an app with a shared UI library it often ends up in the button component itself, not in the template where that particular button is declared.

ng-origin is a side project of mine that tries to fix this. Hold Alt (⌥ on a Mac) in your running dev app, click an element, and a plain-text block with its origin lands in your clipboard. Version 22.0.0 is the first release.

For the Archive button in a dashboard widget, the block looks like this:

Page: /dashboard · route dashboard → DashboardPage (src/app/dashboard/dashboard-page.ts:13)
Element: <button> "Archive"
Inside: UiButton <button ui-button> (ui-kit) · variant=primary
Declared in: Widget (src/app/widget/widget.ts:15)
Projected into: CardShell (src/app/card-shell/card-shell.ts:13)
Template: src/app/widget/widget.html:2
Find: widget.archive
Chain: Widget > DashboardPage
Context: lang=en · viewport=1440×900 (xl)

Declared in is the line I care about most. It names the app component whose template contains the button, with file and line. The library component (UiButton) and the card the button is projected into get their own lines, so they don't get mixed up with it. Find collects search anchors: translation keys, your app's CSS class, data-testid. Every value is read from the running app. Nothing is guessed.

Paste that into your agent, add "make this a secondary button", and it starts in the right file.

npm i -D ng-origin
js
// app.config.ts
import { ApplicationConfig, isDevMode } from '@angular/core';
import { provideNgOrigin } from 'ng-origin';

export const appConfig: ApplicationConfig = {
  providers: [isDevMode() ? [provideNgOrigin()] : []],
};

NgModule apps put the same provider into the root module. Every option is optional. appPrefixes tells it which CSS classes are yours, libraries maps selector prefixes like ui- to a package name, and there are breakpoints, a context callback (current role, language, whatever helps) and extra redact patterns.

With ngx-translate you get the translation keys through a ready-made resolver:

import { ngxTranslateTextKeys } from 'ng-origin/ngx-translate';

provideNgOrigin({ textKeys: ngxTranslateTextKeys() });

It compares the element's text with the translations already loaded for the current language, {{param}} placeholders included.

The Template line needs Angular 22.1.4 or later with enableTemplateSourceLocations in a development tsconfig. Without it, that one line is left out.

modifier: 'ctrl-shift' switches to Ctrl+Shift+Click.window.ngOrigin.describe(element) returns the block without copying it, which is handy in Playwright tests. ng-origin makes no network requests and writes no storage. A block leaves the page only through your clipboard. Input values and the text of form fields are never read, and secret-shaped strings such as JWTs or API keys are replaced with «redacted» before anything is copied. That part is best-effort, so read a block before you paste it somewhere you don't trust.

Production builds drop the runtime and its strings. In dev it loads lazily as its own chunk after bootstrap.

So far only Chromium is tested, and only with a mouse. The peer range allows Angular 20 to 22, but my tests run on 20.3. It also relies on Angular's dev-mode debug API (window.ng), which can change between majors.

The major follows Angular. It's the newest Angular major ng-origin supports, so Angular 23 will bring ng-origin 23, and breaking changes wait for it.

Code and docs are on GitHub, the package is on npm, MIT licensed. If you're on Angular 21 or 22, I'd really like to hear whether it works for you.

── more in #developer-tools 4 stories · sorted by recency
── more on @ng-origin 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/alt-click-any-elemen…] indexed:0 read:3min 2026-12-03 · —