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

Advanced Angular Interview Questions with Code Examples

Advanced Angular Interview Questions with Code Examples Component Communication & State Management 1. Parent-Child Communication with ...

Best for you