What is Route Guard in Angular | Angular Routing | Angular 13+

Published: 20 March 2022
on channel: procademy
21,928
223

In this lecture, we will have a look at Angular Route Guards. The Angular supports several route guards like CanActivate, CanDeactivate, Resolve, CanLoad, and CanActivateChild. These guards help us to secure the route or to perform some actions before navigating into a route or leaving the route.

We use the Angular Guards to control, whether the user can navigate to or away from the current route.

We looked at how to configure our routes and navigate to the different parts of our application using Angular Router. Allowing the user to navigate to all parts of the application is not a good idea. We need to restrict the user until the user performs specific actions like login. Angular provides the Route Guards for this same purpose.

One of the common scenario, where we use Route guards is authentication. We want our App to stop the unauthorized user from accessing the protected route. We can achieve this by using a route guard in Angular.

Uses of Angular Route Guards
- To Confirm the navigational operation
- Asking whether to save before moving away from a view
- Allow access to certain parts of the application to specific users
- Validating the route parameters before navigating to the route
- Fetching some data before you display the component.

The Angular Router supports Five different guards, which you can use to protect the route
- CanActivate
- CanDeactivate
- Resolve
- CanLoad
- CanActivateChild

DOWNLOAD SECTION SOURCE CODE HERE: https://drive.google.com/file/d/16SYO...


Watch video What is Route Guard in Angular | Angular Routing | Angular 13+ online without registration, duration hours minute second in high quality. This video was added by user procademy 20 March 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 21,92 once and liked it 22 people.