Angular guards with example

Angular, guards are used to control access to certain routes based on conditions. They allow you to decide whether a user can navigate to a particular route or not, and they can also be used to execute some logic before entering or leaving a route.


There are four types of guards in Angular:


1. CanActivate - Determines if a route can be activated.

2. CanActivateChild - Determines if a child route can be activated.

3. CanDeactivate - Determines if the current route can be deactivated.

4. Resolve - Resolves data before a route is activated.

5. CanLoad - Determines if a route can be loaded, often used with lazy-loaded routes.

 

No comments:

Post a Comment

Angular's new httpResource and a bonus hidden feature

  The first   release candidate   for   Angular 19.2   is out, and it includes the new experimental   httpResource . This is essentially a s...

Best for you