How would I implement "ngif" to a routerlink instead of creating a button?
example: *ngIf="auth.isAuthenticated()" (click)="auth.logout()"
To: <a [routerLink]="['/']">Logout
How would I implement "ngif" to a routerlink instead of creating a button?
example: *ngIf="auth.isAuthenticated()" (click)="auth.logout()"
To: <a [routerLink]="['/']">Logout
You can put ngIf
on any element. In your case <a *ngIf="auth.isAuthenticated()" [routerLink]="['/']">Logout</a>
should work fine.
Try this
<span *ngIf="auth.isAuthenticated()"><a [routerLink]="['/']">Logout</a></span>