1
- import { Component , NgModule , OnInit } from '@angular/core' ;
1
+ import { Component , NgModule , OnDestroy , OnInit } from '@angular/core' ;
2
2
import { MatCardModule } from '@angular/material' ;
3
3
import { CommonModule } from '@angular/common' ;
4
4
import { ActivatedRoute , Params , RouterModule } from '@angular/router' ;
@@ -7,15 +7,17 @@ import {ComponentPageTitle} from '../page-title/page-title';
7
7
import { SvgViewerModule } from '../../shared/svg-viewer/svg-viewer' ;
8
8
import { Observable } from 'rxjs/Observable' ;
9
9
import 'rxjs/add/observable/combineLatest' ;
10
+ import { Subscription } from 'rxjs/Subscription' ;
10
11
11
12
12
13
@Component ( {
13
14
selector : 'app-component-category-list' ,
14
15
templateUrl : './component-category-list.html' ,
15
16
styleUrls : [ './component-category-list.scss' ]
16
17
} )
17
- export class ComponentCategoryList implements OnInit {
18
+ export class ComponentCategoryList implements OnInit , OnDestroy {
18
19
params : Observable < Params > ;
20
+ routeParamSubscription : Subscription ;
19
21
20
22
constructor ( public docItems : DocumentationItems ,
21
23
public _componentPageTitle : ComponentPageTitle ,
@@ -26,6 +28,16 @@ export class ComponentCategoryList implements OnInit {
26
28
this . params = Observable . combineLatest (
27
29
this . _route . pathFromRoot . map ( route => route . params ) ,
28
30
Object . assign ) ;
31
+
32
+ // title on topbar navigation
33
+ this . routeParamSubscription = this . params . subscribe ( params => {
34
+ const sectionName = params [ 'section' ] ;
35
+ this . _componentPageTitle . title = SECTIONS [ sectionName ] ;
36
+ } ) ;
37
+ }
38
+
39
+ ngOnDestroy ( ) {
40
+ this . routeParamSubscription . unsubscribe ( ) ;
29
41
}
30
42
}
31
43
0 commit comments