Showing posts with label Route Guard. Show all posts
Showing posts with label Route Guard. Show all posts

Wednesday, October 10, 2018

Route Guard example in Angular 6


Let us extent our Angular Routs example and add some route guards to the example. Let us add the most basic route guard CanActivate to the example. Let us begin by adding 2 services auth service and a route-guard service as follows.

ng g s auth
ng g s route-guard

Angular Route Guards

Route Guards are special validation checks which can be used to validate requests to load specific routes/modules, we can validate the request and either accept or deny the request to load the route. Route guards return a true/false value which decides where the user can access the route or not.

There are 5 route guards