Skip to content

Commit

Permalink
test(*): using pageTitleService
Browse files Browse the repository at this point in the history
page title is set for home, dashboard
  • Loading branch information
xmlking committed Sep 23, 2018
1 parent 0da6c6d commit 1fce1af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
11 changes: 7 additions & 4 deletions libs/core/src/lib/services/page-title.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { Title } from '@angular/platform-browser';
providedIn: 'root',
})
export class PageTitleService {
_title = '';
private readonly defaultTitle;
private _title = '';

get title(): string {
return this._title;
Expand All @@ -17,10 +18,12 @@ export class PageTitleService {
set title(title: string) {
this._title = title;
if (title !== '') {
title = `${title} | `;
title = `${title} |`;
}
this.bodyTitle.setTitle(`${title}IS360`);
this.bodyTitle.setTitle(`${title} ${this.defaultTitle}`);
}

constructor(private bodyTitle: Title) {}
constructor(private bodyTitle: Title) {
this.defaultTitle = bodyTitle.getTitle() || 'WebApp';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Actions, Store } from '@ngxs/store';
import { ConnectWebSocket, DisconnectWebSocket } from '@ngx-starter-kit/socketio-plugin';
import { OAuthService } from 'angular-oauth2-oidc';
import { environment } from '@env/environment';
import { PageTitleService } from '@ngx-starter-kit/core';

@Component({
selector: 'ngx-dashboard-layout',
Expand All @@ -33,9 +34,12 @@ export class DashboardLayoutComponent implements OnInit, OnDestroy {
private actions$: Actions,
private media: ObservableMedia,
private oauthService: OAuthService,
private pageTitleService: PageTitleService,
) {}

ngOnInit() {
this.pageTitleService.title = 'Dashboard';

this._mediaSubscription = this.media.subscribe((change: MediaChange) => {
const isMobile = change.mqAlias === 'xs' || change.mqAlias === 'sm';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { routerTransition } from '@ngx-starter-kit/animations';
import { PageTitleService } from '@ngx-starter-kit/core';

@Component({
selector: 'ngx-home-layout',
Expand All @@ -8,7 +9,9 @@ import { routerTransition } from '@ngx-starter-kit/animations';
animations: [routerTransition],
})
export class HomeLayoutComponent implements OnInit {
constructor() {}
constructor(private pageTitleService: PageTitleService) {}

ngOnInit() {}
ngOnInit() {
this.pageTitleService.title = 'Home';
}
}

0 comments on commit 1fce1af

Please sign in to comment.