Files
everything-claude-code/docs/ja-JP/skills/angular-developer/references/router-lifecycle.md
Claude 174e31b3fc feat(ja-JP): add skill sub-reference translations (angular, remotion, etc.)
Translated 85 skill sub-reference files to achieve full parity with
the English source:

- skills/angular-developer/references/ — 35 files (all references)
- skills/remotion-video-creation/rules/ — 28 files (all rules)
- skills/tinystruct-patterns/references/ — 5 files
- skills/openclaw-persona-forge/references/ — 6 files
- skills/skill-comply/prompts/ — 3 files
- skills/lead-intelligence/agents/ — 4 files
- skills/brand-voice/references/ — 1 file
- skills/frontend-slides/ — 2 files
- hooks/memory-persistence/README.md — 1 file

English source parity: 0 missing files (excluding rules/zh/, internal
docs, and experimental examples absent from zh-CN)
2026-05-18 06:15:26 +09:00

46 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ルーターのライフサイクルとイベント
Angular ルーターは `Router.events` オブザーバブルを通じてイベントを発行し、開始から終了までのナビゲーションのライフサイクルを追跡できます。
## 主要なルーターイベント(時系列順)
1. **`NavigationStart`**:ナビゲーションが開始されます。
2. **`RoutesRecognized`**:ルーターが URL をルートにマッチさせます。
3. **`GuardsCheckStart` / `End`**`canActivate``canMatch` などの評価が行われます。
4. **`ResolveStart` / `End`**:データ解決フェーズ(リゾルバーによるデータの取得)。
5. **`NavigationEnd`**:ナビゲーションが正常に完了しました。
6. **`NavigationCancel`**:ナビゲーションがキャンセルされました(例:ガードが `false` を返した)。
7. **`NavigationError`**:ナビゲーションが失敗しました(例:リゾルバーでのエラー)。
## イベントのサブスクライブ
`Router` を注入して `events` オブザーバブルをフィルタリングします。
```ts
import {Router, NavigationStart, NavigationEnd} from '@angular/router';
export class MyService {
private router = inject(Router);
constructor() {
this.router.events.pipe(filter((e) => e instanceof NavigationEnd)).subscribe((event) => {
console.log('Navigated to:', event.url);
});
}
}
```
## デバッグ
アプリケーション起動時にすべてのルーティングイベントの詳細なコンソールログを有効化します。
```ts
provideRouter(routes, withDebugTracing());
```
## よくあるユースケース
- **ローディングインジケーター**`NavigationStart` が発火したときにスピナーを表示し、`NavigationEnd`/`Cancel`/`Error` で非表示にします。
- **アナリティクス**`NavigationEnd` をリッスンしてページビューを追跡します。
- **スクロール管理**:カスタムスクロール動作のために `Scroll` イベントに応答します。