0

How would I implement "ngif" to a routerlink instead of creating a button?

example: *ngIf="auth.isAuthenticated()" (click)="auth.logout()"

To: <a [routerLink]="['/']">Logout

4

2 回答 2

0

You can put ngIf on any element. In your case <a *ngIf="auth.isAuthenticated()" [routerLink]="['/']">Logout</a> should work fine.

于 2018-02-16T07:08:23.523 回答
0

尝试这个

<span  *ngIf="auth.isAuthenticated()"><a [routerLink]="['/']">Logout</a></span>
于 2018-02-16T07:10:04.880 回答