Files
everything-claude-code/docs/ja-JP/skills/angular-developer/references/route-guards.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

1.8 KiB
Raw Blame History

ルートガード

ルートガードは、ユーザーがルートへ遷移できるか、またはルートから離れられるかを制御します。

ガードの種類

  • CanActivate:ユーザーはこのルートにアクセスできるか?(例:認証チェック)
  • CanActivateChild:ユーザーはこのルートの子にアクセスできるか?
  • CanDeactivate:ユーザーはこのルートから離れられるか?(例:未保存の変更)
  • CanMatch:このルートはマッチングの対象として考慮すべきか?(例:フィーチャーフラグ)false を返すと、ルーターは他のルートのチェックを継続します。

ガードの作成

Angular 15 以降、ガードは通常、関数として定義します。

export const authGuard: CanActivateFn = (route, state) => {
  const authService = inject(AuthService);
  const router = inject(Router);

  if (authService.isLoggedIn()) {
    return true;
  }

  // ログインページへリダイレクト
  return router.parseUrl('/login');
};

ガードの適用

ルート設定に配列として追加します。順番通りに実行されます。

{
  path: 'admin',
  component: Admin,
  canActivate: [authGuard],
  canActivateChild: [adminChildGuard],
  canDeactivate: [unsavedChangesGuard]
}

戻り値

  • booleantrue で許可、false でブロック。
  • UrlTree または RedirectCommand:別のルートへリダイレクト。
  • Observable または Promise:上記の型に解決されます。

セキュリティに関する注意

クライアントサイドのガードはサーバーサイドのセキュリティの代わりにはなりません。 サーバー側で常に権限を検証してください。