1
- import { ChangeDetectionStrategy , Component , EventEmitter , Input , Output } from '@angular/core' ;
1
+ import { ChangeDetectionStrategy , Component , EventEmitter , Input , OnChanges , Output } from '@angular/core' ;
2
2
import { ActivatedRoute } from '@angular/router' ;
3
3
import { IconType } from '@hypertrace/assets-library' ;
4
4
import { Color , NavigationService } from '@hypertrace/common' ;
@@ -25,7 +25,7 @@ import { IconSize } from '../icon/icon-size';
25
25
<hr *ngSwitchCase="'${ NavItemType . Divider } '" class="nav-divider" />
26
26
27
27
<ng-container *ngSwitchCase="'${ NavItemType . Link } '">
28
- <ht-nav-item [config]="item" [active]="item === activeItem" [collapsed]="this.collapsed"> </ht-nav-item>
28
+ <ht-nav-item [config]="item" [active]="item === activeItem" [collapsed]="this.collapsed"></ht-nav-item>
29
29
</ng-container>
30
30
</ng-container>
31
31
</ng-container>
@@ -48,7 +48,7 @@ import { IconSize } from '../icon/icon-size';
48
48
</nav>
49
49
`
50
50
} )
51
- export class NavigationListComponent {
51
+ export class NavigationListComponent implements OnChanges {
52
52
@Input ( )
53
53
public navItems : NavItemConfig [ ] = [ ] ;
54
54
@@ -64,12 +64,14 @@ export class NavigationListComponent {
64
64
@Output ( )
65
65
public readonly collapsedChange : EventEmitter < boolean > = new EventEmitter ( ) ;
66
66
67
- public readonly activeItem$ : Observable < NavItemLinkConfig | undefined > ;
67
+ public activeItem$ ? : Observable < NavItemLinkConfig | undefined > ;
68
68
69
69
public constructor (
70
70
private readonly navigationService : NavigationService ,
71
71
private readonly activatedRoute : ActivatedRoute
72
- ) {
72
+ ) { }
73
+
74
+ public ngOnChanges ( ) : void {
73
75
this . activeItem$ = this . navigationService . navigation$ . pipe (
74
76
startWith ( this . navigationService . getCurrentActivatedRoute ( ) ) ,
75
77
map ( ( ) => this . findActiveItem ( this . navItems ) )
0 commit comments