In this blog I’ll show you how to guard routes in Angular 2 Router (currently at 3.0.0-beta.2).
Let’s consider some scenarios that require a certain validation to be performed to decide if the user (or a program) is allowed to navigate to or leave the route:
Allowed to open the route only if the user is authenticated and authorized to do so.
Implement a multi-part form that consists of several components, and the user is allowed to navigate to the next form section only if the data entered in the current one is valid.