{"slug": "alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding", "title": "Alt+Click any element in your Angular app and hand its origin to your coding agent", "summary": "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.", "body_md": "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.\n\nng-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.\n\nFor the Archive button in a dashboard widget, the block looks like this:\n\n```\nPage: /dashboard · route dashboard → DashboardPage (src/app/dashboard/dashboard-page.ts:13)\nElement: <button> \"Archive\"\nInside: UiButton <button ui-button> (ui-kit) · variant=primary\nDeclared in: Widget (src/app/widget/widget.ts:15)\nProjected into: CardShell (src/app/card-shell/card-shell.ts:13)\nTemplate: src/app/widget/widget.html:2\nFind: widget.archive\nChain: Widget > DashboardPage\nContext: lang=en · viewport=1440×900 (xl)\n```\n\n`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.\n\nPaste that into your agent, add \"make this a secondary button\", and it starts in the right file.\n\n```\nnpm i -D ng-origin\njs\n// app.config.ts\nimport { ApplicationConfig, isDevMode } from '@angular/core';\nimport { provideNgOrigin } from 'ng-origin';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [isDevMode() ? [provideNgOrigin()] : []],\n};\n```\n\nNgModule 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.\n\nWith ngx-translate you get the translation keys through a ready-made resolver:\n\n``` js\nimport { ngxTranslateTextKeys } from 'ng-origin/ngx-translate';\n\nprovideNgOrigin({ textKeys: ngxTranslateTextKeys() });\n```\n\nIt compares the element's text with the translations already loaded for the current language, `{{param}}` placeholders included.\n\nThe `Template` line needs Angular 22.1.4 or later with `enableTemplateSourceLocations` in a development tsconfig. Without it, that one line is left out.\n\n`modifier: 'ctrl-shift'` switches to Ctrl+Shift+Click.`window.ngOrigin.describe(element)` returns the block without copying it, which is handy in Playwright tests.\nng-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.\n\nProduction builds drop the runtime and its strings. In dev it loads lazily as its own chunk after bootstrap.\n\nSo 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.\n\nThe 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.\n\nCode and docs are on [GitHub](https://github.com/alexander-spies/ng-origin), the package is on [npm](https://www.npmjs.com/package/ng-origin), MIT licensed. If you're on Angular 21 or 22, I'd really like to hear whether it works for you.", "url": "https://wpnews.pro/news/alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding", "canonical_source": "https://dev.to/alexanderspies/altclick-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding-agent-4773", "published_at": "2026-12-03 20:39:57+00:00", "updated_at": "2026-12-03 20:47:10.593289+00:00", "lang": "en", "topics": ["developer-tools", "ai-tools", "ai-agents"], "entities": ["ng-origin", "Angular", "ngx-translate", "Playwright", "GitHub", "npm"], "also_reported_by": [], "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", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding", "markdown": "https://wpnews.pro/news/alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding.md", "text": "https://wpnews.pro/news/alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding.txt", "jsonld": "https://wpnews.pro/news/alt-click-any-element-in-your-angular-app-and-hand-its-origin-to-your-coding.jsonld"}}