How to hide admin link in view html. I have to guard :Admin and Manager
Router config :
{
path: \'manager\',
component: ManagerComponent,
canAct
Also if already answered in a way which might be helpful, I used here another approach. As you already have your canActivate method in the Guard, you could also inject your navigation component with that Guards and you can call these canActivate methods directly:
In your component which holds the navigation
constructor(private adminGuard: AdminGuard)
and then in the template
-
User
Edit
This does not work in prod mode in my case (if you use parameters which have to be injected). I just tried to compile it but angular complains about the missing parameters. If you do not use parameters, this works fine, or, if you do not use the parameters in your function - then simply pass
-
User
Another thing: If you is variables like the 'adminGuard' above in the template, it must be public - not private.