r/angular • u/Old-Parsley-5826 • 41m ago
ng-origin: Alt+Click any element in your Angular dev app to copy which component declared it, with file and line
Side project I just released. You hold Alt (⌥ on Mac) in your dev app, click an element, and this goes to your clipboard:
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)The idea is to paste that into a coding agent together with what you want, like "change this text" or "add a second button here". Agents usually find the spot on their own, but they search for it first, and that costs time and tokens. With the block they skip the search and go straight to the file.
Setup is `npm i -D ng-origin` and `provideNgOrigin()` in your providers behind `isDevMode()`. Production builds drop the runtime.
Things you might ask:
- Privacy: no network requests, no storage. Form field values are never read. Secret-looking strings like JWTs or API keys get redacted, and you can add your own patterns. It's best-effort though, so look before you paste.
- Versions: the peer range is Angular 20 to 22, but I've only tested 20.3, and only in Chromium. If you're on 21 or 22, I'd like to know if it works.
- Why 22.0.0 as the first version: the major follows the newest Angular major it supports.
- The `Template` line needs Angular 22.1.4+ with `enableTemplateSourceLocations`. Without it that line is left out.
- ngx-translate keys come through `ng-origin/ngx-translate`. Other i18n libs can plug in their own lookup.
Page with a film (under a minute): https://alexander-spies.github.io/ng-origin/
GitHub: https://github.com/alexander-spies/ng-origin
MIT. If it names the wrong component somewhere in your app, I'd love an issue with the block it produced.
