Created
March 1, 2017 03:16
-
-
Save Falci/e395ddd3f977fc204e499aaa31b198ff to your computer and use it in GitHub Desktop.
Angular2 Title utility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment