A route guard controls whether navigation or route activation proceeds, commonly restricting enterprise pages according to a user's authentication status. section 3.3 section 3.3.1
The older approach defines an injectable class implementing CanActivate. Its canActivate method returns a boolean or an UrlTree redirect, while injected services provide authentication state and router navigation. section 3.3.1
Modern Angular can discard the class and express the same behavior as a CanActivateFn. The inject function preserves dependency injection while reducing boilerplate and improving composability. section 3.3.1 section 1.4.3
Protecting HRMS employee pages
An authGuard injects AuthService and Router, observes isAuth$, and maps authenticated users to true; unauthenticated users receive a URL tree for /login. Register it with canActivate: [authGuard] on the employees route, including a lazy-loaded child route.

