NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
Angular Route Switcher is a UserScript tool designed for Angular developers.
It automatically detects your application's routes and provides a floating, draggable UI to quickly switch between them.
Angular Route Switcher 是一個專為 Angular 開發者設計的 UserScript 工具。
它能自動偵測應用程式中的路由,並提供一個可拖曳的懸浮介面,讓您快速切換頁面。

window.ng in Dev Mode).window.ng)。Cmd+K (or Ctrl+K) to toggle the menu, and Arrow keys to navigate.Cmd+K (或 Ctrl+K) 快速開關選單,並使用方向鍵進行導航。http://localhost:4200).http://localhost:4200)。Crucial for Router Detection / 路由偵測的重要設定
To ensure the script detects the Angular Router correctly, you MUST expose the router in your root component (e.g.,
app.component.ts).
為了確保腳本能正確偵測 Angular Router,您 必須 在根元件(例如app.component.ts)中將 router 暴露出來。Recommended Code / 推薦寫法:
export class AppComponent { // ✅ Publicly expose the router using inject / 使用 inject 公開暴露 router router = inject(Router); }Using
privateor constructor injection without exposing it as a public property may cause detection failure.
若使用private或建構式注入而未將其公開,可能會導致偵測失敗。
| Shortcut (Mac/Win) | Action | 功能 |
|---|---|---|
Cmd + K / Ctrl + K |
Toggle Menu | 開啟 / 關閉選單 |
Arrow Up 使用上鍵 |
Focus Previous | 上一個項目 |
Arrow Down 使用下鍵 |
Focus Next | 下一個項目 |
Enter |
Navigate to Route | 跳轉至該路由 |
This tool leverages the debugging APIs exposed by Angular in Development Mode.
本工具利用了 Angular 在 開發模式 下暴露的除錯 API 來運作。
Accessing Angular Context / 取得 Angular Context:
It looks for the window.ng object and uses ng.getComponent() to retrieve the root component instance of your application.
腳本會尋找 window.ng 物件,並使用 ng.getComponent() 來取得應用程式的根元件實例。
Extracting Routes / 提取路由:
Once the root component (or the Router instance) is found, it traverses the router.config to build a flat list of all available routes.
找到根元件(或 Router 實例)後,它會遍歷 router.config 來建構一個完整的可用路由清單。
Navigation / 路由切換:
When you click a route, it calls the Angular Router's navigateByUrl() method directly. This ensures a seamless page transition without triggering a full page reload, just like a native Angular navigation.
當您點擊路由時,它會直接呼叫 Angular Router 的 navigateByUrl() 方法。這能確保頁面切換順暢且不需重新載入整頁,就如同原生的 Angular 導航一樣。
Rating: 0