What I want to achieve is very basic here. In an Angular2 application, I have the following flow:
- user goes to my app
- the app shows an input view (
/whatever
) with inputs and all - user clicks on a save button
- the app shows a summary view (
/summary
)
What I need is for the summary view to be accessible only by pressing the button on the input view. This means:
- the user gets redirected when on the summary view and reloading the page
- the user gets redirected when trying to access the summary view directly by typing the
/summary
url in the browser - the user gets redirected when accessing the summary view from another page which is not input view
What I tried is to implement a safeGuard for the summary view using canActivate
. The problem is, I can't find a way to get the previous url !
canActivate(route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): boolean {
// return previous_url == '/whatever'
// how to find previous_url ???
}
Any help on how to get the previous url in a guard or another way to achieve this is welcome.