Let's say I have two routes in Angular 14: user and admin. I also have a component called some-content.
user.component.html:
<app-some-content></app-some-content>
admin.component.html (same as user.component.html):
<app-some-content></app-some-content>
some-content.component.ts:
export class SomeContentComponent implements OnInit {
constructor(private _router: Router) { }
router: Router = this._router;
some-content.component.html:
<table>
<thead>
<th>Last name</th>
<th>First name</th>
<th>Some stuff</th>
<th>Some other stuff</th>
</thead>
<tbody>
<tr *ngFor="let person of persons">
<td>{{person.lastName}}</td>
<td>{{person.firstName}}</td>
<td *ngIf="router.url === '/user'">{{person.someStuff}}</td>
<td *ngIf="router.url === '/admin'" (click)="callSomeFunction()">{{person.someStuff}}</td>
<td *ngIf="router.url === '/admin'">
<!-- html stuff -->
</td>
</tr>
</tbody>
</table>
As you can see, I used the Router service property url with *ngIf to show/hide data based on the actual view. Just a few lines of code needed, but is it the proper way to do things?