Fix Route Active Indicator
All checks were successful
Quality Check / Linting (push) Successful in 23s
All checks were successful
Quality Check / Linting (push) Successful in 23s
This commit is contained in:
parent
1dca4a1f4f
commit
c846650556
1 changed files with 4 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
import {Location} from '@angular/common';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {MatAnchor, MatButton} from '@angular/material/button';
|
||||
import {MatIcon} from '@angular/material/icon';
|
||||
|
@ -20,7 +21,8 @@ export class HeaderComponent implements OnInit {
|
|||
routes: Array<{ path: string, title: string, class: string }> = [];
|
||||
|
||||
constructor(
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private location: Location
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -31,7 +33,7 @@ export class HeaderComponent implements OnInit {
|
|||
.map(route => ({
|
||||
path: `/${route.path}`,
|
||||
title: route.title as string,
|
||||
class: `/${route.path}` == this.router.url ? 'active' : ''
|
||||
class: `/${route.path}` == (this.location.path() || '/') ? 'active' : ''
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue