1- import { Component , NgModule , OnInit } from '@angular/core' ;
1+ import { Component , NgModule , OnDestroy , OnInit } from '@angular/core' ;
22import { MatCardModule } from '@angular/material' ;
33import { CommonModule } from '@angular/common' ;
44import { ActivatedRoute , Params , RouterModule } from '@angular/router' ;
@@ -7,15 +7,17 @@ import {ComponentPageTitle} from '../page-title/page-title';
77import { SvgViewerModule } from '../../shared/svg-viewer/svg-viewer' ;
88import { Observable } from 'rxjs/Observable' ;
99import 'rxjs/add/observable/combineLatest' ;
10+ import { Subscription } from 'rxjs/Subscription' ;
1011
1112
1213@Component ( {
1314 selector : 'app-component-category-list' ,
1415 templateUrl : './component-category-list.html' ,
1516 styleUrls : [ './component-category-list.scss' ]
1617} )
17- export class ComponentCategoryList implements OnInit {
18+ export class ComponentCategoryList implements OnInit , OnDestroy {
1819 params : Observable < Params > ;
20+ routeParamSubscription : Subscription ;
1921
2022 constructor ( public docItems : DocumentationItems ,
2123 public _componentPageTitle : ComponentPageTitle ,
@@ -26,6 +28,16 @@ export class ComponentCategoryList implements OnInit {
2628 this . params = Observable . combineLatest (
2729 this . _route . pathFromRoot . map ( route => route . params ) ,
2830 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 ( ) ;
2941 }
3042}
3143
0 commit comments