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 project for this recipe resides in chapter07/start_here/using-route-guards
:
- Open the project in Visual Studio Code.
- Open the terminal and run
npm install
to install the dependencies of the project. - Once done, run
ng serve -o
.This should open the app in a new browser tab, and you should see the app as follows:
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...