Is there a better way than using *ngIfs to achieve a role-based navigation in Angular?

by Tim   Last Updated September 05, 2017 14:05 PM

In my navigation menu I want to display links to other pages depending on the role of the user. Is there a better way than using *ngIfs like this ?

<ul class="nav">
    <li routerLinkActive="active"><a [routerLink]="['/home']" *ngIf="authService.hasRole('admin')">Home</a></li>
    <li routerLinkActive="active"><a [routerLink]="['/admin']" *ngIf="authService.hasRole('user')">Admin</a></li>
</ul>
Tags : angular2


Related Questions





MEAN stack vs ASP.NET

Updated March 30, 2017 19:05 PM