0

I use router and guards with CanActivate. It works fine, but I need show only in my menu the "activable" links.

Has router any option as "isActivable"?

Example:

<ul>
 <li routerLink="home" routerLinkActive="active" *ngIf="isActivable">Home</li>
<ul>
MiguelAngel_LV
  • 1,200
  • 5
  • 16

1 Answers1

0

You can just inject your Guard in the constructor of your Component. Like this:

constructor(private yourGuard: YourGuard){}

And int the Template:

<ul>
 <li routerLink="home" routerLinkActive="active" *ngIf="yourGuard.canActivate()">Home</li>
<ul>

Of course you have to specify your guard in the Router...

Spitzbueb
  • 5,233
  • 1
  • 20
  • 38