Commit 9f8ffa55 authored by Christopher Fullarton's avatar Christopher Fullarton

Optimizes setting of the document title

parent 9dfc1f2f
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
@Injectable({
......@@ -16,16 +16,16 @@ export class HeaderLabelService {
set headerLabel(value: string) {
this._headerLabel = value;
if (isPlatformBrowser(this.platformId)) {
if (value === 'default') {
document.title = 'arsnova.click';
} else {
this.translateService.get(value).subscribe(translatedValue => document.title = 'arsnova.click - ' + translatedValue);
}
if (!value || value === 'default') {
this.titleService.setTitle('arsnova.click');
} else {
this.translateService.get(value).subscribe(translatedValue => {
this.titleService.setTitle('arsnova.click - ' + translatedValue);
});
}
}
constructor(@Inject(PLATFORM_ID) private platformId: Object, private translateService: TranslateService) {
constructor(@Inject(PLATFORM_ID) private platformId: Object, private translateService: TranslateService, private titleService: Title) {
this.translateService.onLangChange.subscribe(() => {
this.headerLabel = this._headerLabel;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment