Skip to content

Commit

Permalink
Update page title for section view (angular#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
sumiet authored and jelbourn committed Dec 12, 2017
1 parent 082db46 commit 66a1967
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/pages/component-category-list/component-category-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, NgModule, OnInit} from '@angular/core';
import {Component, NgModule, OnDestroy, OnInit} from '@angular/core';
import {MatCardModule} from '@angular/material';
import {CommonModule} from '@angular/common';
import {ActivatedRoute, Params, RouterModule} from '@angular/router';
Expand All @@ -7,15 +7,17 @@ import {ComponentPageTitle} from '../page-title/page-title';
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/combineLatest';
import {Subscription} from 'rxjs/Subscription';


@Component({
selector: 'app-component-category-list',
templateUrl: './component-category-list.html',
styleUrls: ['./component-category-list.scss']
})
export class ComponentCategoryList implements OnInit {
export class ComponentCategoryList implements OnInit, OnDestroy {
params: Observable<Params>;
routeParamSubscription: Subscription;

constructor(public docItems: DocumentationItems,
public _componentPageTitle: ComponentPageTitle,
Expand All @@ -26,6 +28,16 @@ export class ComponentCategoryList implements OnInit {
this.params = Observable.combineLatest(
this._route.pathFromRoot.map(route => route.params),
Object.assign);

// title on topbar navigation
this.routeParamSubscription = this.params.subscribe(params => {
const sectionName = params['section'];
this._componentPageTitle.title = SECTIONS[sectionName];
});
}

ngOnDestroy() {
this.routeParamSubscription.unsubscribe();
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app/pages/component-sidenav/component-sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ComponentSidenav implements OnInit {
this.sidenav.close();
}
});

// Combine params from all of the path into a single object.
this.params = Observable.combineLatest(
this._route.pathFromRoot.map(route => route.params),
Expand Down

0 comments on commit 66a1967

Please sign in to comment.