angular-router
Angularアプリケーションで、ナビゲーション、ルーティング設定、遅延読み込み、パラメータ処理などを効率的に実装するSkill。
📜 元の英語説明(参考)
Angular Router for navigation, routing configuration, route guards, lazy loading, and parameter handling. Use when setting up routes, implementing navigation guards, lazy loading modules, handling route parameters, or implementing breadcrumbs and nested routes in Angular applications.
🇯🇵 日本人クリエイター向け解説
Angularアプリケーションで、ナビゲーション、ルーティング設定、遅延読み込み、パラメータ処理などを効率的に実装するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o angular-router.zip https://jpskill.com/download/6836.zip && unzip -o angular-router.zip && rm angular-router.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/6836.zip -OutFile "$d\angular-router.zip"; Expand-Archive "$d\angular-router.zip" -DestinationPath $d -Force; ri "$d\angular-router.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
angular-router.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
angular-routerフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Angular Router スキル
ルール
ルーター設定
- スタンドアロンアプリケーションでは
app.config.tsでprovideRouter(routes)を使用してください。 - ルートは別の
routes.tsファイルで定義してください。 - 空のパスのリダイレクトには
pathMatch: 'full'を使用してください。 - 404 処理のために、ワイルドカードルート (
**) を最後のルートとして含めてください。
遅延ロード
- フィーチャールートの遅延ロードには
loadChildrenを使用してください。 - スタンドアロンコンポーネントの遅延ロードには
loadComponentを使用してください。 - ルート設定でフィーチャーモジュールを先行してインポートしないでください。
ルートガード
- 依存性注入には
inject()を使用した関数型ガードを使用してください。 - ガードからは
booleanまたはUrlTreeを返してください。 - ガードのリダイレクトには
router.createUrlTree(['/path'])を使用してください。 - クラスベースのガード (CanActivate, CanDeactivate インターフェース) は使用しないでください。
ルートパラメーター
- ルートパラメーターにアクセスするには
toSignal(route.params, { initialValue })を使用してください。 - クエリパラメーターにアクセスするには
toSignal(route.queryParams, { initialValue })を使用してください。 - ルートオブザーバブルをシグナルに変換する際には
initialValueを提供してください。 route.paramsまたはroute.queryParamsを手動で購読しないでください。
ナビゲーション
- プログラムによるナビゲーションには
router.navigate(['/path'])を使用してください。 - テンプレートによるナビゲーションには
[routerLink]="['/path']"を使用してください。 window.locationを介して URL を直接操作しないでください。
コンテキスト
このスキルを使用するタイミング
以下の必要がある場合にこのスキルをアクティブにしてください。
- アプリケーションのルートを設定する
- ルートガード (CanActivate, CanDeactivate, Resolve) を実装する
- フィーチャーモジュールの遅延ロードを設定する
- ルートパラメーターとクエリパラメーターを処理する
- ネストされたルートと子ルートを実装する
- ナビゲーションメニューとブレッドクラムを作成する
- ルート遷移とアニメーションを処理する
- ルートのリダイレクトとワイルドカードを実装する
- ルーターイベントとナビゲーションライフサイクルを操作する
基本的な設定
// app.routes.ts
import { Routes } from '@angular/router';
export const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', component: NotFoundComponent }
];
// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes)
]
};
遅延ロード
// Feature module lazy loading
export const routes: Routes = [
{
path: 'admin',
loadChildren: () => import('./admin/admin.routes')
.then(m => m.ADMIN_ROUTES)
},
{
path: 'workspace',
loadComponent: () => import('./workspace/workspace.component')
.then(m => m.WorkspaceComponent)
}
];
ルートガード
// Auth guard
import { inject } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from './auth.service';
export const authGuard = () => {
const authService = inject(AuthService);
const router = inject(Router);
if (authService.isAuthenticated()) {
return true;
}
return router.createUrlTree(['/login']);
};
// Apply guard
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [authGuard]
}
ルートパラメーター
// Route with parameter
{ path: 'user/:id', component: UserDetailComponent }
// Access in component
export class UserDetailComponent {
private route = inject(ActivatedRoute);
userId = toSignal(
this.route.params.pipe(map(params => params['id'])),
{ initialValue: null }
);
}
参考文献
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Angular Router Skill
Rules
Router Configuration
- Use
provideRouter(routes)inapp.config.tsfor standalone applications - Define routes in a separate
routes.tsfile - Use
pathMatch: 'full'for empty path redirects - Include wildcard route (
**) as the LAST route for 404 handling
Lazy Loading
- Use
loadChildrenfor lazy loading feature routes - Use
loadComponentfor lazy loading standalone components - Do NOT eagerly import feature modules in route configuration
Route Guards
- Use functional guards with
inject()for dependency injection - Return
booleanorUrlTreefrom guards - Use
router.createUrlTree(['/path'])for guard redirects - Do NOT use class-based guards (CanActivate, CanDeactivate interfaces)
Route Parameters
- Use
toSignal(route.params, { initialValue })to access route parameters - Use
toSignal(route.queryParams, { initialValue })to access query parameters - Provide
initialValuewhen converting route observables to signals - Do NOT manually subscribe to
route.paramsorroute.queryParams
Navigation
- Use
router.navigate(['/path'])for programmatic navigation - Use
[routerLink]="['/path']"for template navigation - Do NOT manipulate URLs directly via
window.location
Context
When to Use This Skill
Activate this skill when you need to:
- Configure application routes
- Implement route guards (CanActivate, CanDeactivate, Resolve)
- Set up lazy loading for feature modules
- Handle route parameters and query parameters
- Implement nested and child routes
- Create navigation menus and breadcrumbs
- Handle route transitions and animations
- Implement route redirects and wildcards
- Work with router events and navigation lifecycle
Basic Setup
// app.routes.ts
import { Routes } from '@angular/router';
export const routes: Routes = [
{ path: '', redirectTo: '/home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: '**', component: NotFoundComponent }
];
// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';
import { routes } from './app.routes';
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes)
]
};
Lazy Loading
// Feature module lazy loading
export const routes: Routes = [
{
path: 'admin',
loadChildren: () => import('./admin/admin.routes')
.then(m => m.ADMIN_ROUTES)
},
{
path: 'workspace',
loadComponent: () => import('./workspace/workspace.component')
.then(m => m.WorkspaceComponent)
}
];
Route Guards
// Auth guard
import { inject } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from './auth.service';
export const authGuard = () => {
const authService = inject(AuthService);
const router = inject(Router);
if (authService.isAuthenticated()) {
return true;
}
return router.createUrlTree(['/login']);
};
// Apply guard
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [authGuard]
}
Route Parameters
// Route with parameter
{ path: 'user/:id', component: UserDetailComponent }
// Access in component
export class UserDetailComponent {
private route = inject(ActivatedRoute);
userId = toSignal(
this.route.params.pipe(map(params => params['id'])),
{ initialValue: null }
);
}