Here is a sample command
1 | Ng generate guard auth |
This will prompt you for which interface should be implemented? I chose CanActivate
There was a copy and paste which populated that class.
A guard can be added to routing
1 | import { AuthGuard } from './auth.guard'; |
Adding canActivate – will call the guard, and if the circumstances being tested within the guard is valid, then that path can be activated.
In my case I have a 3rd party validator (auth0), when you are logged in through this validator, then the Edit path becomes secured.