Setting page title on route change

Change-Id: I9c23d0215c7967eb3eff3a341ab3f210fb16a47a
diff --git a/src/app/core/services/page-title.ts b/src/app/core/services/page-title.ts
new file mode 100644
index 0000000..6f7e0c3
--- /dev/null
+++ b/src/app/core/services/page-title.ts
@@ -0,0 +1,33 @@
+import {StyleConfig} from '../../config/style.config';
+export interface IXosPageTitleService {
+  get(): string;
+  set(title: string): void;
+  formatStateName(stateName: string): string;
+}
+
+export class PageTitle {
+  static $inject = ['$window', '$transitions'];
+  constructor(
+    private $window: angular.IWindowService,
+    private $transitions: any // missing definition
+  ) {
+    console.log('page title');
+    this.$transitions.onSuccess({ to: '**' }, (transtion) => {
+      this.set(this.formatStateName(transtion.$to().name));
+    });
+  }
+
+  get() {
+    return this.$window.document.title;
+  }
+
+  set(title: string) {
+    this.$window.document.title = `${StyleConfig.projectName} - ${title}`;
+  }
+
+  private formatStateName(stateName: string): string {
+    // TODO pluralize and capitalize first letter only
+    return stateName.replace('xos.', '').toUpperCase();
+  }
+}
+