Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 66a1967

Browse files
sumietjelbourn
authored andcommitted
Update page title for section view (#328)
Fixes #296
1 parent 082db46 commit 66a1967

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/app/pages/component-category-list/component-category-list.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, NgModule, OnInit} from '@angular/core';
1+
import {Component, NgModule, OnDestroy, OnInit} from '@angular/core';
22
import {MatCardModule} from '@angular/material';
33
import {CommonModule} from '@angular/common';
44
import {ActivatedRoute, Params, RouterModule} from '@angular/router';
@@ -7,15 +7,17 @@ import {ComponentPageTitle} from '../page-title/page-title';
77
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
88
import {Observable} from 'rxjs/Observable';
99
import '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

src/app/pages/component-sidenav/component-sidenav.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class ComponentSidenav implements OnInit {
3737
this.sidenav.close();
3838
}
3939
});
40+
4041
// Combine params from all of the path into a single object.
4142
this.params = Observable.combineLatest(
4243
this._route.pathFromRoot.map(route => route.params),

0 commit comments

Comments
 (0)