Angular 22 · Routing and forms

Protect a route

Allow navigation only when a condition holds.

export const authGuard: CanActivateFn = () => inject(AuthService).isLoggedIn() || inject(Router).parseUrl('/login');

Official Angular 22 documentation

More routing and forms commands

All routing and forms commands · Angular 22 cheatsheet

Was this page helpful?