Authorized access to routes using route guards
Not all routes in your Angular app should be accessible by everyone in the world. In this recipe, we'll learn how to create route guards in Angular to prevent unauthorized access to routes.
Getting ready
The app that we are going to work with resides in start/apps/chapter07/ng-route-guards
inside the cloned repository:
- Open the code repository in your Code Editor.
- Open the terminal, navigate to the code repository directory and run
npm run serve ng-route-guards
to serve the project
This should open the app in a new browser tab. And you should see the following:
Now that we have the app running locally, let's see the steps of the recipe in the next section.
How to do it…
We have an app with a couple of routes already set up. You can log in as either an employee or an admin to get to the bucket list of the app. However, if you tap any of the two...