如何建立活动链接?

时间:2018-10-27 23:21:39

标签: angular material angular-material-6

Todo:

  • 我要这样做,以便
    在打开某个页面时,边栏中的链接变为活动
    (即,它以某种颜色突出显示)。


代码:

<mat-sidenav-container class="sidenav-container">
  <mat-sidenav
    #drawer
    class="sidenav"
    fixedInViewport="true"
    [attr.role]="isHandset ? 'dialog' : 'navigation'"
    [mode]="(isHandset | async)!.matches ? 'over' : 'side'"
    [opened]="!(isHandset | async)!.matches">
    <mat-toolbar color="primary">Menu</mat-toolbar>
    <mat-nav-list >
      <a mat-list-item href="/admin">Admins</a>
      <a mat-list-item href="/second-page">Second Page</a>
      <a mat-list-item [matMenuTriggerFor]="menu">
        Third Page
      </a>

    </mat-nav-list>
  </mat-sidenav>
  <mat-sidenav-content>
    <mat-toolbar color="primary">
      <button class="transparent"
        type="button"
        aria-label="Toggle sidenav"
        mat-icon-button
        (click)="drawer.toggle()"
        *ngIf="(isHandset | async)!.matches">
        <mat-icon class="fa fa-bars"></mat-icon>
      </button>
      <span>Application Title</span>
    </mat-toolbar>
    <router-outlet></router-outlet>
  </mat-sidenav-content>
</mat-sidenav-container>

1 个答案:

答案 0 :(得分:0)

RouterLinkRouterLinkActive结合使用。