Falci
3/1/2017 - 3:16 AM

Angular2 Title utility

Angular2 Title utility

import {Title} from "@angular/platform-browser";
import {Injectable} from "@angular/core";

@Injectable()
export class TitleService extends Title {

  private prefix: string = '';
  private suffix: string = '';

  setTitle(newTitle: string) {
    super.setTitle(`${this.prefix} ${newTitle} ${this.suffix}`.trim());
  }

  setPrefix(newPrefix: string) {
    this.prefix = newPrefix;
  }

  setSuffix(newSuffix: string) {
    this.suffix = newSuffix;
  }
}